/* Self-hosted fonts (see fonts/LICENSE.md) */
@font-face {
  font-family: "Bodoni Moda";
  src: url("fonts/bodoni-moda.woff2") format("woff2");
  font-style: normal; font-weight: 400 700; font-display: swap;
}
@font-face {
  font-family: "Bodoni Moda";
  src: url("fonts/bodoni-moda-italic.woff2") format("woff2");
  font-style: italic; font-weight: 400 700; font-display: swap;
}
@font-face {
  font-family: "Work Sans";
  src: url("fonts/work-sans.woff2") format("woff2");
  font-style: normal; font-weight: 300 600; font-display: swap;
}

/* Official palette from the visual identity (design/r&b_apresentação.pdf, p. 3) */
:root {
  --bg: #600615;          /* vinho */
  --bg-deep: #4a0410;
  --surface: #6e1221;
  --cream: #f8f6e2;
  --blush: #f7c9cb;
  --sage: #547f54;
  --muted: #d9bdb9;
  --line: rgba(247, 201, 203, .34);
  --danger: #ffd0c2;
  /* Bodoni Moda stands in for Perandory Condensed (commercial) in live text */
  --serif: "Bodoni Moda", Didot, "Bodoni 72", "Times New Roman", serif;
  --sans: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--cream);
  font: 400 16px/1.6 var(--sans);
  padding: max(env(safe-area-inset-top), 0px) 20px max(env(safe-area-inset-bottom), 16px);
  -webkit-font-smoothing: antialiased;
}

svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.5;
      stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- header: the original lockup (design p. 4), then the album title ---- */
body { position: relative; }
.brand { position: relative; z-index: 1; text-align: center; padding: clamp(28px, 7vh, 64px) 0 40px; }
.lockup { display: block; width: min(100%, 620px); height: auto; margin: 0 auto; }
.brand h1 { margin: 0; }

/* Line drawings from the identity's pattern (p. 7) */
.art { display: block; height: auto; margin: 0 auto; }
.art-couple { width: min(48%, 190px); margin-bottom: 18px; }
.art-dove { width: 120px; margin-top: 12px; }
.grid > .art-dove, .grid > .empty { grid-column: 1 / -1; }
.inline-heart { height: 1.3em; width: auto; vertical-align: -.25em; margin-right: .3em; }
.divider { display: block; width: min(70%, 240px); height: auto; margin: 0 auto 28px; opacity: .9; }

/* Toasting hands bleeding off the corners, as on the Save the Date (p. 9) */
.corner { position: absolute; z-index: 0; width: clamp(150px, 17vw, 260px); height: auto; pointer-events: none; }
.corner-tl { top: clamp(24px, 8vh, 96px); left: 0; }
.corner-br { bottom: 0; right: 0; }
@media (max-width: 899px) { .corner { display: none; } }

/* ---- layout ---- */
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; }
.view { animation: fade .4s ease both; }
.narrow { max-width: 380px; margin: 0 auto; }
.center { text-align: center; }
.stack { display: grid; gap: 12px; }

.lead {
  text-align: center;
  font: italic 400 1.2rem/1.45 var(--serif);
  color: var(--blush);
  margin: 0 0 30px;
  text-wrap: balance;
}
.hint { text-align: center; color: var(--muted); font-size: .85rem; font-weight: 300; margin: 18px 0 0; }
.hint.left { text-align: left; margin: 0 0 14px; }
.label { font-size: .72rem; letter-spacing: .26em; text-transform: uppercase; color: var(--muted); text-align: center; }
.error { color: var(--danger); text-align: center; font-size: .9rem; margin: 12px 0 0; }

/* ---- controls ---- */
.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-deep);
  color: var(--cream);
  font: 400 1.15rem var(--sans);
  letter-spacing: .24em;
  text-align: center;
  text-transform: uppercase;
}
.field { position: relative; }
.field .input { padding-inline: 52px; }
.reveal {
  position: absolute; top: 50%; right: 8px; translate: 0 -50%;
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%; background: none;
  color: var(--muted); cursor: pointer;
}
.reveal:hover { color: var(--blush); }
.reveal:focus-visible { outline: 2px solid var(--blush); outline-offset: 1px; }
.input:focus { outline: none; border-color: var(--blush); box-shadow: 0 0 0 3px rgba(233, 168, 166, .18); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  padding: 13px 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font: 400 .8rem var(--sans);
  letter-spacing: .2em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { border-color: var(--blush); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--blush); border-color: var(--blush); color: var(--bg); font-weight: 500; }
.btn.primary:hover { background: #f2bdbb; }
.btn.block { width: 100%; }
.btn.big { padding: 18px 24px; font-size: .88rem; }
.btn.small { padding: 9px 18px; font-size: .72rem; }
.btn:focus-visible, .link:focus-visible, .tile:focus-visible, summary:focus-visible, .segmented button:focus-visible {
  outline: 2px solid var(--blush); outline-offset: 3px;
}

.link {
  background: none; border: 0; padding: 0;
  color: var(--blush); font: 300 .9rem var(--sans);
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; cursor: pointer;
}

/* ---- loading ---- */
.selfie-preview {
  width: 132px; height: 132px; margin: 8px auto 30px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(var(--blush), transparent 70%);
  animation: spin 1.4s linear infinite;
}
.selfie-preview img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
  border: 5px solid var(--bg); background: var(--surface);
  animation: spin 1.4s linear infinite reverse;
}

/* ---- results ---- */
.results-head { display: flex; align-items: center; gap: 16px; margin: 0 0 24px; }
.avatar { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; background: var(--surface); border: 1px solid var(--blush); }
.results-head h2 { margin: 0 0 2px; font: 400 1.9rem/1.1 var(--serif); font-variation-settings: "opsz" 72; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.segmented button {
  border: 0; background: none; color: var(--muted);
  padding: 8px 18px; border-radius: 999px;
  font: 400 .72rem var(--sans); letter-spacing: .2em; text-transform: uppercase; cursor: pointer;
}
.segmented button[aria-checked="true"] { background: var(--blush); color: var(--bg); font-weight: 500; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  margin: 0 -14px 28px;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 0 0 32px; }
}
.tile {
  position: relative; aspect-ratio: 1; padding: 0; border: 0; overflow: hidden;
  background: var(--surface); cursor: zoom-in;
}
@media (min-width: 640px) { .tile { border-radius: 6px; } }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease, opacity .4s ease; opacity: 0; }
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.04); }

.empty { text-align: center; color: var(--muted); padding: 24px 0 8px; }

.maybe { border-top: 1px solid var(--line); padding-top: 20px; margin-bottom: 32px; }
.maybe summary {
  cursor: pointer; list-style: none;
  font: italic 400 1.4rem var(--serif); color: var(--cream); margin-bottom: 14px;
}
.maybe summary::-webkit-details-marker { display: none; }
.maybe summary::after { content: "+"; float: right; color: var(--blush); font: 300 1.4rem var(--sans); }
.maybe[open] summary::after { content: "–"; }
.count { color: var(--muted); font: 300 1rem var(--sans); font-style: normal; }

/* ---- footer ---- */
footer { position: relative; z-index: 1; max-width: 520px; margin: 48px auto 0; padding-top: 20px; text-align: center; color: var(--muted); font-size: .8rem; font-weight: 300; }
.footer-mono { display: block; width: 46px; height: auto; margin: 0 auto 14px; }
.signature { margin: 0 0 18px; font: italic 400 1.1rem var(--serif); color: var(--blush); }
footer summary { cursor: pointer; letter-spacing: .26em; text-transform: uppercase; font-size: .68rem; }
footer p { margin: 10px 0 0; }
.credits { margin-top: 22px !important; font-size: .74rem; letter-spacing: .04em; opacity: .85; }
.credits a { color: var(--blush); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.credits a:hover { text-decoration-color: var(--blush); }

/* ---- viewer ---- */
.viewer {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: rgba(30, 7, 11, .97);
  animation: fade .2s ease both;
  touch-action: pan-y;
}
.viewer img {
  max-width: 100vw;
  max-height: calc(100dvh - 140px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.v-btn {
  position: absolute;
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border: 1px solid var(--line); border-radius: 50%;
  background: rgba(61, 17, 25, .6);
  color: var(--cream); cursor: pointer;
}
.v-btn:hover { border-color: var(--blush); }
.v-close { top: max(16px, env(safe-area-inset-top)); right: 16px; }
.v-prev { left: 16px; top: 50%; translate: 0 -50%; }
.v-next { right: 16px; top: 50%; translate: 0 -50%; }
@media (hover: none) { .v-prev, .v-next { display: none; } }
.v-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px max(20px, env(safe-area-inset-bottom));
  color: var(--muted); font-size: .8rem; letter-spacing: .14em;
}
.v-bar .btn { background: var(--blush); color: var(--bg); border-color: var(--blush); font-weight: 500; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 20;
  translate: -50% 0;
  width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 22px; border-radius: 999px;
  background: var(--blush); color: var(--bg); font-size: .9rem; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  animation: fade .25s ease both;
}

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { rotate: 360deg; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
