/* ---------------------------------------------------------------------------
   beternu — pre-launch gate (Atelier styling)
   An iPhone-style passcode lock + countdown to launch, painted over every
   page while html.gated is set. Self-contained: hardcodes the Atelier palette
   and self-hosts Fraunces/Archivo so it looks identical on any page (incl. Noir).
   Remove the per-page gate includes after launch to retire it.
--------------------------------------------------------------------------- */

/* Self-host the Atelier faces so the gate renders correctly on every page. */
@font-face {
  font-family: "Gate Fraunces";
  src: url("/fonts/fraunces-normal-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Gate Fraunces";
  src: url("/fonts/fraunces-italic-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Gate Archivo";
  src: url("/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --g-ink: #14110c;
  --g-paper: #f3efe6;
  --g-paper-dim: rgba(243, 239, 230, 0.55);
  --g-cobalt: #2742f5;
  --g-rule: rgba(243, 239, 230, 0.16);
  --g-serif: "Gate Fraunces", "Fraunces", Georgia, serif;
  --g-sans: "Gate Archivo", "Archivo", system-ui, sans-serif;
}

/* While locked, the underlying page cannot scroll. The inline head snippet
   already paints a solid backdrop via html.gated::before to prevent any flash. */
html.gated { overflow: hidden !important; }

/* --------------------------------------------------------------------------
   The lock surface
-------------------------------------------------------------------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 2147483647; /* above everything, incl. the inline backdrop */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.6rem, 4vh, 2.8rem);
  padding: clamp(1.5rem, 5vh, 3rem) 1.25rem;
  background: var(--g-ink);
  color: var(--g-paper);
  font-family: var(--g-sans);
  font-weight: 300;
  text-align: center;
  overflow-y: auto;
  transition: transform 0.8s cubic-bezier(0.7, 0, 0.2, 1), opacity 0.6s ease;
}

/* Film grain for Atelier cohesion */
.gate::after {
  content: "";
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: gate-grain 0.9s steps(4) infinite;
}

@keyframes gate-grain {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-2%, 3%); }
  50%  { transform: translate(3%, -2%); }
  75%  { transform: translate(-3%, -3%); }
  100% { transform: translate(2%, 2%); }
}

/* When unlocking, lift the curtain like the Atelier intro */
html.gate-unlocking .gate {
  transform: translateY(-100%);
  opacity: 0;
}

.gate__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.4rem, 3.5vh, 2.4rem);
  width: 100%;
  max-width: 26rem;
}

.gate__kicker {
  font-size: 0.72rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--g-paper-dim);
}

.gate__kicker em {
  color: var(--g-cobalt);
  font-style: normal;
}

/* --------------------------------------------------------------------------
   Countdown
-------------------------------------------------------------------------- */

.gate__count {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(0.7rem, 3vw, 1.4rem);
}

.gate__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  min-width: 3.4rem;
}

.gate__num {
  font-family: var(--g-serif);
  font-weight: 350;
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.gate__cell-label {
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--g-paper-dim);
}

.gate__sep {
  font-family: var(--g-serif);
  font-size: clamp(2rem, 7vw, 3.2rem);
  line-height: 1;
  color: var(--g-cobalt);
  align-self: flex-start;
  margin-top: 0.1em;
}

.gate__when {
  font-family: var(--g-serif);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1rem, 2.6vw, 1.35rem);
  color: var(--g-paper);
}

.gate__when em { color: var(--g-cobalt); font-style: italic; }

.gate__bar { color: var(--g-paper-dim); margin: 0 0.2em; font-style: normal; }

/* "dat is de deadline" struck out — cobalt rule, Atelier style */
.gate__strike {
  text-decoration: line-through;
  text-decoration-color: var(--g-cobalt);
  text-decoration-thickness: 2px;
  text-underline-offset: 0;
  color: var(--g-paper-dim);
  font-style: italic;
}

.gate.is-launch .gate__count { display: none; }
.gate__launch {
  display: none;
  font-family: var(--g-serif);
  font-style: italic;
  font-size: clamp(1.6rem, 6vw, 2.6rem);
  color: var(--g-paper);
}
.gate.is-launch .gate__launch { display: block; }
.gate.is-launch .gate__when { display: none; }

/* --------------------------------------------------------------------------
   Passcode dots
-------------------------------------------------------------------------- */

.gate__lockline {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--g-paper-dim);
}

.gate__dots {
  display: flex;
  gap: 0.95rem;
  justify-content: center;
}

.gate__dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--g-paper);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.gate__dot.is-filled {
  background: var(--g-cobalt);
  border-color: var(--g-cobalt);
}

/* Wrong-code shake */
.gate__dots.is-wrong {
  animation: gate-shake 0.45s ease;
}
.gate__dots.is-wrong .gate__dot {
  border-color: #d8674e;
}

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* --------------------------------------------------------------------------
   Keypad (iPhone style)
-------------------------------------------------------------------------- */

.gate__pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(0.7rem, 2.2vw, 1.1rem);
  width: min(17rem, 82vw);
}

.gate__key {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--g-rule);
  background: transparent;
  color: var(--g-paper);
  font-family: var(--g-sans);
  font-weight: 300;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.08s ease;
}

.gate__key:hover { border-color: var(--g-paper); }
.gate__key:active,
.gate__key.is-press {
  background: var(--g-cobalt);
  border-color: var(--g-cobalt);
  transform: scale(0.96);
}

.gate__key-num {
  font-size: clamp(1.5rem, 5vw, 2rem);
  line-height: 1;
}

.gate__key-abc {
  font-size: 0.5rem;
  letter-spacing: 0.18em;
  color: var(--g-paper-dim);
  min-height: 0.6em;
}

.gate__key:active .gate__key-abc,
.gate__key.is-press .gate__key-abc { color: rgba(243, 239, 230, 0.85); }

.gate__key--ghost {
  border: none;
  background: transparent;
  cursor: default;
  pointer-events: none;
}

.gate__key--del {
  border: none;
  font-size: 1.3rem;
}
.gate__key--del:hover { border: none; color: var(--g-cobalt); }
.gate__key--del:active { background: transparent; transform: scale(0.92); }

.gate__hint {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--g-paper-dim);
  min-height: 1em;
}
.gate__hint em { color: #d8674e; font-style: normal; }

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

/* --------------------------------------------------------------------------
   Reduced motion
-------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   Narrow screens — keep the countdown on one line within the viewport
-------------------------------------------------------------------------- */

@media (max-width: 430px) {
  .gate { overflow-x: hidden; }
  .gate__inner { max-width: 100%; }
  .gate__kicker { font-size: 0.6rem; letter-spacing: 0.18em; }
  .gate__count { gap: 0.3rem; }
  .gate__cell { min-width: 0; gap: 0.3rem; }
  .gate__num { font-size: clamp(1.5rem, 7.2vw, 2rem); }
  .gate__sep { font-size: 1.4rem; margin-top: 0.05em; }
  .gate__cell-label { font-size: 0.5rem; letter-spacing: 0.1em; }
  .gate__when { font-size: 0.92rem; max-width: 18rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gate,
  .gate::after,
  .gate__dots.is-wrong,
  .gate__key {
    animation: none !important;
    transition: none !important;
  }
}
