/* ============================================================
   Diorama Vision — landing page
   Values transcribed 1:1 from Figma ("Design" page):
     Desktop 1440x750  ·  Mobile 402x874
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* palette */
  --black:         #000000;
  --card:          #141516;
  --white:         #ffffff;
  --muted:         #868686;              /* card body / captions on black */
  --muted-on-video: rgba(255, 255, 255, .7);
  --glass:         rgba(255, 255, 255, .1);
  --glass-hover:   rgba(255, 255, 255, .18);
  --tint:          rgba(0, 0, 0, .25);   /* constant scrim over the video */

  /* type */
  --font: "Google Sans Flex", "Google Sans", "Product Sans", -apple-system,
          BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --vf: "GRAD" 0, "ROND" 0, "wdth" 100;
  --track: -.03em;                       /* Figma: -2.4px@80 · -1.92@64 · -.48@16 */

  /* geometry */
  --toggle-w: 106px;                     /* "Contact" pill  (24 + 58 + 24) */
  --toggle-h: 44px;
  --edge-x: 32px;                        /* desktop gutter for the toggle  */
  --edge-y: 32px;
  --logo-w: 145.3px;
  --logo-top: 32px;                      /* top-aligned with the toggle */
  --hero-nudge: 24px;                    /* hero sits 24px below true centre */
  --cards-nudge: 31.5px;                 /* Figma: top calc(50% + 31.5px)   */

  /* motion */
  --ease-out: cubic-bezier(.16, 1, .3, 1);      /* gentle, expo-ish settle  */
  --ease-in:  cubic-bezier(.55, 0, 1, .45);     /* crisp exit               */
  --ease-soft: cubic-bezier(.33, 1, .68, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-variation-settings: var(--vf);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;                      /* single-screen experience */
  overscroll-behavior: none;
}

h1, h2, p { margin: 0; }
button { font: inherit; color: inherit; border: 0; background: none; }
img { display: block; }

:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ============================================================
   Backdrop — video, constant tint, animated black scrim
   ============================================================ */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #0b0b0c;
  overflow: hidden;
}

.backdrop__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  transform-origin: 50% 50%;
  transition: transform 1100ms var(--ease-out);
  will-change: transform;
}

.backdrop__tint {
  position: absolute;
  inset: 0;
  background: var(--tint);
}

/* Fades to solid black when the contact view opens. */
.backdrop__scrim {
  position: absolute;
  inset: 0;
  background: var(--black);
  opacity: 0;
  transition: opacity 640ms var(--ease-soft) 260ms;  /* closing: waits for the cards to clear */
}

[data-view="contact"] .backdrop__video { transform: scale(1.06); }
[data-view="contact"] .backdrop__scrim {
  opacity: 1;
  transition: opacity 620ms var(--ease-soft) 60ms;   /* opening */
}

/* ============================================================
   Logo — identical placement in both views
   ============================================================ */
.logo {
  position: fixed;
  top: var(--logo-top);
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: block;
  line-height: 0;
  transition: opacity 400ms var(--ease-soft);
}
.logo img { width: var(--logo-w); height: auto; }
.logo:hover { opacity: .8; }

/* ============================================================
   Toggle — "Contact" pill morphs into the close button
   ============================================================ */
.toggle {
  position: fixed;
  top: var(--edge-y);
  right: var(--edge-x);
  z-index: 40;

  display: block;
  width: var(--toggle-w);
  height: var(--toggle-h);
  padding: 0;
  border-radius: 9999px;
  background: var(--glass);
  cursor: pointer;
  overflow: hidden;

  transition:
    width      520ms var(--ease-soft),
    background 320ms var(--ease-soft);
}
.toggle:hover { background: var(--glass-hover); }

/* Both children fill the button and centre their own contents, so they
   cross-fade in place. They are absolutely positioned rather than sharing a
   grid cell: an auto grid track cannot shrink below the label's 55.57px
   min-content width, which pushed the 24px cross ~5.8px off centre once the
   button collapsed to 44px. */
.toggle__label,
.toggle__icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.toggle__label {
  font-size: 16px;
  line-height: .85;
  letter-spacing: var(--track);
  white-space: nowrap;
  transition: opacity 160ms var(--ease-in), transform 380ms var(--ease-out);
}

.toggle__icon {
  opacity: 0;
  transform: rotate(-90deg) scale(.6);
  transition: opacity 220ms var(--ease-soft), transform 520ms var(--ease-out);
}

[data-view="contact"] .toggle { width: var(--toggle-h); }      /* 106 → 44 */
[data-view="contact"] .toggle__label {
  opacity: 0;
  transform: scale(.8);
  transition-duration: 140ms, 240ms;
}
[data-view="contact"] .toggle__icon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
  transition-delay: 200ms;
}

/* ============================================================
   Views
   ============================================================ */
.view {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
}
.view[inert] { pointer-events: none; }

/* ---------- Home ---------- */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  /* Figma's text box is 939.691px. Browsers add trailing letter-spacing that
     Figma omits, which pushes line 2 ~8px over that limit and forces a third
     line — 960px restores the design's exact two-line break. */
  width: min(960px, 100% - 40px);
  transform: translateY(var(--hero-nudge));
  text-align: center;
}

.hero__text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.hero__title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 198.609px;                  /* Figma text-box height */
  font-weight: 500;
  font-size: 80px;
  line-height: 1;
  letter-spacing: var(--track);
  color: var(--white);
  word-break: break-word;
}

.hero__subtitle {
  font-weight: 400;
  font-size: 24px;
  line-height: 1;
  color: var(--white);
}

/* ---------- Contact ---------- */
.cards {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  width: min(600px, 100vw - 44px);        /* 600 desktop · 358 @402 mobile */
  transform: translateY(var(--cards-nudge));
}

.card {
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
  padding: 32px;
  border-radius: 32px;
  background: var(--card);
}

.card__head {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card__title {
  font-weight: 500;
  font-size: 64px;
  line-height: 1;
  letter-spacing: var(--track);
  color: var(--white);
}
.card__title--sm { font-size: 32px; }

.card__body {
  font-weight: 400;
  font-size: 18px;
  line-height: 1.3;
  color: var(--muted);
}

.mail { display: flex; flex-direction: column; gap: 8px; }

.mail__label { font-size: 18px; line-height: 1; color: var(--muted); }

.mail__address {
  font-size: 18px;
  line-height: 1;
  color: var(--white);
  text-decoration: none;
  width: fit-content;
  transition: opacity 240ms var(--ease-soft);
}
.mail__address:hover { opacity: .7; text-decoration: underline; text-underline-offset: 3px; }

.mail__note { font-size: 12px; line-height: 1; color: var(--muted); }

/* ============================================================
   Shared CTA
   ============================================================ */
.cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 154px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  padding: 16px 24px;
  border-radius: 999px;
  background: var(--white);
  color: var(--black);
  font-size: 16px;
  line-height: .85;
  letter-spacing: var(--track);
  white-space: nowrap;
  cursor: pointer;
  -webkit-backdrop-filter: blur(25px);
  backdrop-filter: blur(25px);
  transition: transform 420ms var(--ease-out), box-shadow 420ms var(--ease-out);
}
.btn:hover  { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.btn:active { transform: translateY(0)    scale(.98); transition-duration: 120ms; }

.cta__note {
  font-size: 14px;
  line-height: 1;
  text-align: center;
  width: 100%;
  color: var(--muted-on-video);
}
.cta__note--dark { color: var(--muted); }

/* ============================================================
   Transition choreography
   ============================================================ */

/* — Home content — */
.hero {
  opacity: 1;
  filter: blur(0);
  transition:
    opacity   700ms var(--ease-out) 340ms,
    transform 800ms var(--ease-out) 340ms,
    filter    700ms var(--ease-out) 340ms,
    visibility 0ms linear 0ms;
  visibility: visible;
}
[data-view="contact"] .hero {
  opacity: 0;
  transform: translateY(calc(var(--hero-nudge) - 18px)) scale(.97);
  filter: blur(6px);
  visibility: hidden;
  transition:
    opacity   340ms var(--ease-in),
    transform 420ms var(--ease-in),
    filter    340ms var(--ease-in),
    visibility 0ms linear 420ms;
}

/* — Contact cards (staggered) — */
.cards { visibility: hidden; transition: visibility 0ms linear 420ms; }
[data-view="contact"] .cards { visibility: visible; transition-delay: 0ms; }

.card {
  opacity: 0;
  transform: translateY(24px) scale(.97);
  filter: blur(8px);
  transition:
    opacity   340ms var(--ease-in) calc((1 - var(--i)) * 60ms),
    transform 420ms var(--ease-in) calc((1 - var(--i)) * 60ms),
    filter    340ms var(--ease-in) calc((1 - var(--i)) * 60ms);
}
[data-view="contact"] .card {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
  transition:
    opacity   720ms var(--ease-out) calc(340ms + var(--i) * 90ms),
    transform 820ms var(--ease-out) calc(340ms + var(--i) * 90ms),
    filter    720ms var(--ease-out) calc(340ms + var(--i) * 90ms);
}

/* ============================================================
   Responsive — Mobile frame (402 x 874)
   ============================================================ */
@media (max-width: 639.98px) {
  :root {
    --edge-x: 20px;
    --edge-y: 28px;
    --logo-w: 120.7px;
    --logo-top: 32.5px;
    --hero-nudge: 35.5px;
    --cards-nudge: 46.5px;
  }

  /* Mobile logo is left-aligned, not centred. */
  .logo {
    left: 28.8px;
    transform: none;
  }

  .hero__title    { font-size: 48px; }
  .card__title    { font-size: 48px; }
  .card__title--sm{ font-size: 32px; }
}

/* Fluid band between the two Figma frames. */
@media (min-width: 640px) {
  .hero__title { font-size: clamp(48px, 5.5556vw, 80px); }   /* 1440 → 80 */
}

@media (max-width: 380px) {
  .hero__title { font-size: 40px; min-height: 0; }
  .card__title { font-size: 40px; }
}

/* Short viewports: let the hero breathe instead of clipping. */
@media (max-height: 620px) {
  .hero__title { min-height: 0; }
  .hero { gap: 24px; }
}

/* ============================================================
   Reduced motion — keep it, but make it instant and flat
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 160ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
  .hero, [data-view="contact"] .hero,
  .card, [data-view="contact"] .card {
    transform: none;
    filter: none;
  }
  .hero { transform: translateY(var(--hero-nudge)); }
  .cards { transform: translateY(var(--cards-nudge)); }
  .backdrop__video { transform: none !important; }
}

/* ============================================================
   First-paint lock — prevents a deep-link to /contact from
   animating in from the home state. Removed by app.js.
   ============================================================ */
.no-anim *,
.no-anim *::before,
.no-anim *::after {
  transition: none !important;
  animation: none !important;
}

/* ============================================================
   Overflow safety for short viewports
   ============================================================ */
.view--home,
.view--contact {
  /* `safe center` keeps the pixel-exact centring when the content fits, and
     falls back to top-aligned + scrollable when the viewport is too short —
     no padding, so the Figma offsets stay untouched. */
  align-content: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.view--contact::-webkit-scrollbar,
.view--home::-webkit-scrollbar { width: 0; height: 0; }
