/* Mela HTML export layout (from sample exports) + app chrome */

:root {
  --background-color: rgba(255, 255, 255, 1);
  --color: rgba(0, 0, 0, 0.75);
  --secondary-color: rgba(0, 0, 0, 0.5);
  --tertiary-color: rgba(0, 0, 0, 0.33);
  --quaternary-color: rgba(0, 0, 0, 0.17);
  --secondary-background-color: rgba(0, 0, 0, 0.025);
  --secondary-border-color: rgba(0, 0, 0, 0.05);
  --tint-color: rgb(224, 96, 80);
  --app-bar: 3.25rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background-color: rgba(30, 30, 30, 1);
    --color: rgba(255, 255, 255, 0.9);
    --secondary-color: rgba(255, 255, 255, 0.6);
    --tertiary-color: rgba(255, 255, 255, 0.4);
    --quaternary-color: rgba(255, 255, 255, 0.2);
    --secondary-background-color: rgba(255, 255, 255, 0.025);
    --secondary-border-color: rgba(255, 255, 255, 0.05);
    --tint-color: rgb(254, 215, 9);
  }
}

* {
  box-sizing: border-box;
  text-size-adjust: none;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background-color: var(--background-color);
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
  font: -apple-system-body;
  line-height: 1.8;
  color: var(--color);
}

h1 {
  margin: 0;
  padding: 0;
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 800;
  color: var(--color);
  line-height: 1.2;
}

h3 {
  margin: 0;
  padding: 0;
  font-size: 1em;
  font-weight: 600;
  color: var(--color);
}

* + h3,
div.instructions div + div > h3 {
  padding-top: 1.8em;
}

a {
  color: var(--tint-color);
  text-decoration: none;
  font-weight: 600;
}

ol {
  list-style-type: none;
  counter-reset: li;
  margin: 0;
  padding: 0;
}

ol li:before {
  counter-increment: li;
  content: counter(li);
  padding-right: 0.3em;
  color: var(--quaternary-color);
  display: inline-block;
}

ul {
  list-style-type: none;
  margin: 0 0 0 1em;
  padding: 0;
}

sup,
sub {
  position: relative;
  font-size: 0.6em;
  line-height: 1;
}
sup {
  top: 0.1em;
}
sub {
  bottom: 0.3em;
}

div p,
div ol,
div ol li {
  padding: 0;
  margin: 1.5em 0;
}

div h3:first-child,
div p:first-child,
div ul:first-child,
div ul:first-child li:first-child,
div ol:first-child,
div ol:first-child li:first-child {
  margin-top: 0;
}

div h3:last-child,
div p:last-child,
div ul:last-child,
div ul:last-child li:last-child,
div ol:last-child,
div ol:last-child li:last-child {
  margin-bottom: 0;
}

/* —— Recipe columns (Mela) —— */

#recipe-view main > div > div {
  padding: 40px 40px;
  max-width: 41em;
  margin: 0 auto;
}

#recipe-view main > div > span:first-child {
  display: block;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  padding-top: 100%;
}

#recipe-view main > div > div {
  position: relative;
}

#recipe-view main > div:not(#title) > div:before {
  content: " ";
  position: absolute;
  top: 0;
  height: 1px;
  left: 17%;
  right: 17%;
  background-color: var(--quaternary-color);
  transform: scaleY(0.5);
}

#title .description {
  font-weight: 500;
}

#instructions,
#ingredients {
  color: var(--secondary-color);
}

strong {
  color: var(--color);
  font-weight: 600;
}

#ingredients i {
  color: var(--tertiary-color);
}

#ingredients h3 {
  margin-bottom: 0;
}
#ingredients * + h3 {
  margin-top: 0;
}

#ingredients > span:first-child {
  display: none;
}

.ingredients li {
  line-height: 1.2;
  margin-top: 1em;
  margin-bottom: 1em;
}

#instructions .notes {
  font-style: italic;
}

#instructions .nutrition {
  line-height: 1.2;
}
#instructions .nutrition p {
  margin: 0.5em 0;
}

#info {
  padding: 0;
  overflow: hidden;
  font-size: 0.8em;
  font-weight: 600;
  margin-left: -0.8em;
}
#info .group {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  line-height: 1em;
  vertical-align: top;
  padding: 0.3em 0;
}
#info .group .info {
  display: inline-block;
  position: relative;
  height: 3em;
  line-height: 3em;
  padding: 0 1em;
  color: var(--color);
  text-decoration: none;
}
#info .group .info.labeled {
  padding-top: 0.7em;
  line-height: 1em;
}
#info .group .info.icon {
  padding-left: 3em;
}
#info .group .info:before {
  content: " ";
  position: absolute;
  left: -0.15em;
  top: 0.5em;
  bottom: 0.5em;
  width: 1px;
  background-color: var(--quaternary-color);
}
#info .group .info.icon:after {
  opacity: 0.8;
  content: " ";
  position: absolute;
  left: 0.5em;
  top: 0;
  width: 2.5em;
  height: 100%;
  background-size: 20px 20px;
  background-position: center center;
  background-repeat: no-repeat;
}
#info .group label {
  position: relative;
  display: block;
  font-size: 0.8em;
  text-transform: uppercase;
  color: var(--tertiary-color);
}

.icon.source:after {
  background-image: url("/icons/source.png");
}
.icon.servings:after {
  background-image: url("/icons/servings.png");
}
.icon.timer:after {
  background-image: url("/icons/timer.png");
}

@media (prefers-color-scheme: dark) {
  #info .group .info.icon:after {
    opacity: 1;
    filter: invert(100%);
  }
}

@media (max-width: 500px) {
  #recipe-view main > div > div {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (min-width: 720px) {
  #recipe-view {
    position: fixed;
    inset: var(--app-bar) 0 0 0;
    overflow: hidden;
  }
  #recipe-view main {
    height: 100%;
  }
}

@media (min-width: 720px) and (max-width: 1099px) {
  #title > span:first-child {
    display: none;
  }
  #ingredients > span:first-child {
    display: block;
  }

  #recipe-view main {
    position: absolute;
    left: 0;
    right: 38%;
    top: 0;
    bottom: 0;
    overflow: scroll;
    overscroll-behavior: contain;
    padding-bottom: 100px;
  }

  #ingredients {
    position: fixed;
    left: 62%;
    right: 0;
    top: var(--app-bar);
    bottom: 0;
    overflow: scroll;
    overscroll-behavior: contain;
    background-color: var(--secondary-background-color);
    border-left: 1px solid var(--secondary-border-color);
    padding-bottom: 100px;
  }

  #ingredients > .ingredients:before {
    display: none;
  }
}

@media (min-width: 1100px) {
  #title > span:first-child {
    display: block;
  }
  #ingredients > span:first-child {
    display: none;
  }

  #recipe-view main {
    position: absolute;
    left: 0;
    right: 67%;
    top: 0;
    bottom: 0;
    overflow: scroll;
    overscroll-behavior: contain;
    padding-bottom: 100px;
    background-color: var(--secondary-background-color);
    border-right: 1px solid var(--secondary-border-color);
  }

  #instructions {
    position: fixed;
    left: 33%;
    right: 33%;
    top: var(--app-bar);
    bottom: 0;
    overflow: scroll;
    overscroll-behavior: contain;
    padding-bottom: 100px;
  }

  #ingredients {
    position: fixed;
    left: 67%;
    right: 0;
    top: var(--app-bar);
    bottom: 0;
    overflow: scroll;
    overscroll-behavior: contain;
    padding-bottom: 100px;
    background: transparent;
    border-left: none;
  }

  #ingredients > .ingredients:before {
    display: none;
  }

  #instructions > div:first-child:before {
    display: none;
  }
}

/* —— App chrome —— */

#app-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--app-bar);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--background-color) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--secondary-border-color);
}

#app-bar a.brand {
  font-family: ui-serif, Georgia, serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--color);
  white-space: nowrap;
}

#app-bar .spacer {
  flex: 1;
}

#app-bar input[type="search"] {
  flex: 1;
  min-width: 0;
  max-width: 28rem;
  border: 1px solid var(--secondary-border-color);
  background: var(--secondary-background-color);
  color: var(--color);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font: inherit;
}

#app-bar button,
#app-bar a.btn {
  appearance: none;
  border: 1px solid var(--secondary-border-color);
  background: var(--secondary-background-color);
  color: var(--color);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

#app-bar button.primary,
#app-bar a.btn.primary {
  background: var(--tint-color);
  border-color: transparent;
  color: #111;
}

#app-bar button:disabled {
  opacity: 0.5;
  cursor: default;
}

#list-view {
  max-width: 52rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

#list-view .meta {
  color: var(--tertiary-color);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

#list-view .empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--secondary-color);
}

#list-view .empty code {
  font-size: 0.9em;
}

.recipe-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.recipe-card {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.9rem;
  align-items: center;
  padding: 0.65rem;
  border-radius: 12px;
  border: 1px solid var(--secondary-border-color);
  background: var(--secondary-background-color);
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
}

.recipe-card:hover {
  border-color: var(--quaternary-color);
}

.recipe-card .thumb {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 8px;
  background: var(--quaternary-color);
  background-size: cover;
  background-position: center;
}

.recipe-card .body {
  min-width: 0;
}

.recipe-card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: ui-serif, Georgia, serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color);
}

.recipe-card .sub {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--tertiary-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recipe-card .cats {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--secondary-color);
}

#upload-view {
  max-width: 32rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

#upload-view h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

#upload-view p {
  color: var(--secondary-color);
}

#upload-view label {
  display: block;
  margin: 1.25rem 0 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

#upload-view input[type="password"],
#upload-view input[type="file"] {
  width: 100%;
  font: inherit;
}

#upload-view input[type="password"] {
  border: 1px solid var(--secondary-border-color);
  background: var(--secondary-background-color);
  color: var(--color);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

#upload-view .actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#upload-view .status {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: var(--secondary-color);
  white-space: pre-wrap;
}

#upload-view .status.error {
  color: #c44;
}

#upload-view .status.ok {
  color: #2a7;
}

.hidden {
  display: none !important;
}

#recipe-view .back {
  position: fixed;
  top: calc(var(--app-bar) + 0.75rem);
  left: 0.75rem;
  z-index: 40;
  background: color-mix(in srgb, var(--background-color) 85%, transparent);
  border: 1px solid var(--secondary-border-color);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--color);
}

@media (min-width: 1100px) {
  #recipe-view .back {
    /* sits over title column */
  }
}
