@import "./tokens.css";

:root {
  --color-bg: #241f1c;
  --color-card: #978b7f;
  --color-ink: #1c1b19;
  --color-ink-soft: rgba(28, 27, 25, 0.88);
  --color-paper: #f4f1ea;
  --color-line: rgba(28, 27, 25, 0.45);
  --color-exit: #d9d9d4;          /* exit plates' studio grey, so the walk-off has no seam */
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius-card: 28px;
  --gutter: var(--space-6);
}

html, body {
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  /* tokens.css sets 100vh, which on iOS Safari is the large viewport and leaks a scroll */
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  display: grid;
  place-items: center;
  padding: var(--gutter);
}

.card {
  position: relative;
  /* sized by width AND height so the page never scrolls on short laptop screens */
  width: min(1100px, 100%, calc((100vh - 2 * var(--gutter)) * 1.6));
  width: min(1100px, 100%, calc((100dvh - 2 * var(--gutter)) * 1.6));
  aspect-ratio: 16 / 10;
  background: var(--color-card);
  border-radius: var(--radius-card);
  overflow: hidden;
  transition: background-color var(--duration-slow) var(--ease);
}

/* a soft paper wash behind the band keeps small dark type above 4.5:1 on the taupe */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 34%;
  z-index: var(--z-raised);
  background: linear-gradient(to bottom, rgba(244, 241, 234, 0.24), rgba(244, 241, 234, 0));
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease);
}

.figure {
  position: absolute;
  inset: 0;
  z-index: var(--z-base);
}

.figure img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;   /* keeps the headset clear of the lede at every desktop size */
  opacity: 0;
  transition: opacity var(--duration-base) linear;
  pointer-events: none;
  user-select: none;
}

.figure img.on { opacity: 1; }

.card.white { background: var(--color-exit); }
.card.white::before { opacity: 0; }

.card.white .figure {
  top: 0;
  mask-image: none;
  -webkit-mask-image: none;
}

.card.white .figure img { object-position: center; }

.card.white .band,
.card.white .send {
  opacity: 0;
  pointer-events: none;
}

.band, .send { transition: opacity var(--duration-base) var(--ease); }

/* the plate's edges fade as he walks off, so no grey rectangle shrinks across the card */
.figure.recede img.on {
  animation: recede 1.7s ease-in forwards;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 38%, transparent 70%);
  mask-image: radial-gradient(ellipse at center, #000 38%, transparent 70%);
}

@keyframes recede {
  from { transform: scale(1) translateY(0); }
  to { transform: scale(0.015) translateY(-40%); opacity: 0; }
}

.dot {
  position: absolute;
  z-index: var(--z-raised);
  left: 50%;
  top: 42%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--color-ink);
}

.band {
  position: absolute;
  z-index: var(--z-nav);
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-6);
  align-items: start;
  padding: 28px 36px 0;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.lede {
  font-size: 14px;
  font-weight: 550;
  line-height: 1.35;
  white-space: nowrap;
  color: var(--color-ink);
}

.field {
  /* sized on the label, not the input: a right-aligned grid item shrinks to fit, which left Email narrower than Name */
  width: min(280px, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-ink-soft);
}

.field.email {
  justify-self: end;
  text-align: right;
}

.field input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--color-line);
  background: transparent;
  color: var(--color-ink);
  font: 500 16px/1.4 var(--font-body);
  letter-spacing: 0;
  text-transform: none;
  padding: 8px 0;
  border-radius: 0;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.field input:hover { border-bottom-color: rgba(28, 27, 25, 0.7); }

/* 2px ink underline on focus, drawn with a shadow so nothing shifts */
.field input:focus,
.field input:focus-visible {
  border-bottom-color: var(--color-ink);
  box-shadow: 0 1px 0 var(--color-ink);
}

.field.email input { text-align: right; }

/* house contrast rule: placeholders at 0.80 ink minimum; typed text stays heavier (500 vs 400) */
.field input::placeholder { color: rgba(28, 27, 25, 0.8); font-weight: 400; }

.mark {
  margin: 0;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--color-ink);
  font: 650 32px/1 var(--font-body);
  letter-spacing: -0.04em;
}

.send {
  position: absolute;
  z-index: var(--z-nav);
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  border: 0;
  cursor: pointer;
  background: var(--color-ink);
  color: var(--color-paper);
  font: 650 13px/1 var(--font-body);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 14px 24px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(28, 27, 25, 0.25);
  transition: opacity var(--duration-base) var(--ease), background-color var(--duration-base) var(--ease),
              box-shadow var(--duration-base) var(--ease), transform var(--duration-fast) var(--ease);
}

.send:not(:disabled):hover {
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 8px 20px rgba(28, 27, 25, 0.35);
}

.send:not(:disabled):active { transform: translateX(-50%) scale(0.97); }

/* inactive but still legible: solid, muted, no lift */
.send:disabled {
  background: rgba(28, 27, 25, 0.5);
  color: rgba(244, 241, 234, 0.9);
  box-shadow: none;
  cursor: not-allowed;
}

.send.ready { animation: settle 360ms var(--ease); }

@keyframes settle {
  0%   { transform: translateX(-50%) scale(0.94); }
  60%  { transform: translateX(-50%) scale(1.04); }
  100% { transform: translateX(-50%) scale(1); }
}

.status {
  position: absolute;
  z-index: var(--z-nav);
  left: 0;
  right: 0;
  bottom: 74px;
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink);
  min-height: 1.2em;
}

/* failure message sits on the taupe card over his chest, give it a pill so it reads */
.status.err:not(:empty) {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(244, 241, 234, 0.92);
  white-space: nowrap;
}

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

:focus-visible {
  outline: 2px solid var(--color-ink);
  outline-offset: 3px;
}

/* short or narrow landscape (landscape phones, small windows): keep the 3-column band, drop the lede so
   the fields keep usable width */
@media (orientation: landscape) and (max-width: 900px), (orientation: landscape) and (max-height: 500px) {
  :root { --gutter: 10px; --radius-card: 18px; }
  .lede { display: none; }
  .band { padding: 14px 20px 0; gap: 16px; }
  .mark { font-size: 24px; }
  .field { width: min(220px, 100%); }
  .field input { padding: 6px 0; }
  .send { bottom: 14px; padding: 11px 20px; }
  .status { bottom: 58px; }
}

/* phones and portrait tablets: portrait card that fills the screen, band stacks mark-first */
@media (orientation: portrait) and (max-width: 1000px) {
  :root { --gutter: 12px; --radius-card: 22px; }
  .card {
    width: 100%;
    height: calc(100vh - 2 * var(--gutter));
    height: calc(100dvh - 2 * var(--gutter));
    max-height: 940px;
    aspect-ratio: auto;
  }
  .card::before { height: 46%; }
  .band {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 14px;
    padding: 22px 18px 0;
  }
  .brand { order: -1; gap: 8px; margin-bottom: 2px; }
  .lede { white-space: normal; max-width: 26ch; text-wrap: balance; }
  .field, .field.email { justify-self: center; text-align: center; }
  .field.email input { text-align: center; }
  .field { width: min(280px, 80vw); }
  .field input { text-align: center; }
  .mark { font-size: 30px; }
  .figure {
    top: clamp(250px, 30%, 320px);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 36px);
    mask-image: linear-gradient(to bottom, transparent, #000 36px);
  }
  .figure img { object-position: center 30%; }
  .send { bottom: 20px; }
  .status { bottom: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .figure img { transition: none; }
  .figure.recede img.on { animation: none; transform: scale(0.04); opacity: 0; }
  .send.ready { animation: none; }
}
