/* ---------------------------------------------------------------------------
   Peltify — the way in.  2026-08-28.

   Spotify's login, in Peltify's paper: one column, a heading, labelled
   fields, one full-width primary button, an "or" rule, a provider button with
   its mark on the left, and the way across underneath. Rectangles throughout
   (Nick: "too childish and bubbly … more AWS, Azure feel. Strong. Bold and
   professional."). Tokens come from tokens.css; nothing here invents a colour.
   --------------------------------------------------------------------------- */

.auth {
  min-height: 100dvh;
  display: grid;
  align-content: start;
  justify-items: center;
  padding: clamp(28px, 8vh, 88px) 16px 40px;
  background: var(--paper);
}
.auth-body { width: min(400px, 100%); }
.auth-card {
  display: flex; flex-direction: column; gap: 18px;
  padding: 0;
  background: transparent;
}
.auth-mark { display: block; height: 30px; width: auto; margin: 0 auto 6px; }
.auth-card h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
  color: var(--ink);
}
.auth-lede {
  margin: -8px 0 0; text-align: center;
  font-size: 14px; line-height: 1.5; color: var(--ink-soft);
}
.auth-lede b { color: var(--ink); font-weight: 700; }

/* ---- fields ---- */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label {
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em; color: var(--ink);
}
.auth-field input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-box);
  background: var(--white); color: var(--ink);
  font: inherit; font-size: 15px;
  transition: border-color var(--fast, 120ms) var(--ease, ease);
}
.auth-field input::placeholder { color: var(--ink-faint); }
.auth-field input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 1px var(--ink); }
.auth-hint { font-size: 12px; color: var(--ink-faint); }
.auth-expiry { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.auth-expiry.is-expired { color: var(--warn, #b26a00); font-weight: 600; }
.auth-pw, .auth-handle { position: relative; display: flex; align-items: stretch; }
.auth-pw input, .auth-handle input { flex: 1 1 auto; padding-right: 76px; }
.auth-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 32px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-box);
  background: var(--white); color: var(--ink-soft);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.auth-eye:hover { color: var(--ink); border-color: var(--line-strong); }
.auth-handle .auth-mark {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  height: auto; margin: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; color: var(--ink-faint);
  pointer-events: none;
}
.auth-handle .auth-mark.is-ok { color: #1f7a3a; }
.auth-handle .auth-mark.is-bad { color: #b3261e; }
.auth-code {
  text-align: center; letter-spacing: 0.42em; font-size: 24px !important;
  font-weight: 700; font-variant-numeric: tabular-nums; height: 56px !important;
}
.auth-err { margin: -4px 0 0; font-size: 13px; color: #b3261e; }
.auth-err[hidden] { display: none; }

/* ---- buttons ---- */
.auth-stack { display: flex; flex-direction: column; gap: 10px; }
.auth-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; height: 46px; padding: 0 18px;
  border: 1px solid var(--ink); border-radius: var(--r-box);
  background: var(--white); color: var(--ink);
  font: inherit; font-size: 15px; font-weight: 700; letter-spacing: -0.005em;
  cursor: pointer;
  transition: background var(--fast, 120ms) var(--ease, ease), color var(--fast, 120ms) var(--ease, ease),
              transform var(--fast, 120ms) var(--ease, ease);
}
.auth-btn:hover { background: var(--paper-deep, var(--paper)); }
.auth-btn.is-primary { background: var(--ink); color: var(--white); }
.auth-btn.is-primary:hover { background: var(--violet); border-color: var(--violet); }
.auth-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.auth-btn:active:not(:disabled) { transform: translateY(1px); }
.auth-row { display: flex; gap: 10px; }
.auth-row .auth-btn { width: auto; flex: 1 1 0; }

.auth-or {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-faint); font-size: 12.5px; font-weight: 600;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }

.auth-provider {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; height: 46px; padding: 0 48px;
  border: 1px solid var(--line-strong); border-radius: var(--r-box);
  background: var(--white); color: var(--ink);
  font: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
}
.auth-provider:hover:not(:disabled) { border-color: var(--ink); }
.auth-provider:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-provider-mark {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  display: inline-grid; place-items: center; width: 18px; height: 18px;
}
.auth-provider-mark svg { display: block; }
.auth-provider-off { display: flex; flex-direction: column; gap: 6px; }
.auth-why { margin: 0; font-size: 12px; line-height: 1.45; color: var(--ink-faint); }

/* ---- the way across ---- */
.auth-cross {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px;
  margin: 0; font-size: 13.5px; color: var(--ink-soft); text-align: center;
}
.auth-cross-sub { font-size: 12px; color: var(--ink-faint); }
.auth-dot { color: var(--ink-faint); }
.auth-link {
  border: 0; padding: 0; background: none;
  font: inherit; font-size: inherit; font-weight: 700; color: var(--ink);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.auth-link:hover { color: var(--violet); }
.auth-link:disabled { opacity: 0.5; cursor: wait; }

.auth-legal {
  margin: 6px 0 0; font-size: 11.5px; line-height: 1.5; text-align: center;
  color: var(--ink-faint);
}
.auth-legal a { color: var(--ink-soft); text-decoration: underline; text-underline-offset: 2px; }

/* ---- notices ---- */
.auth-note {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 0; padding: 11px 13px;
  border: 1px solid var(--line); border-left-width: 3px;
  border-radius: var(--r-box);
  background: var(--white);
  font-size: 13px; line-height: 1.45; color: var(--ink-soft);
}
.auth-note svg { flex: none; margin-top: 2px; }
.auth-note.is-ok { border-left-color: #1f7a3a; }
.auth-note.is-warn { border-left-color: #b26a00; }
.auth-note.is-bad { border-left-color: #b3261e; }
.auth-note .auth-link { margin-left: 4px; }
.auth-restore {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border: 1px solid var(--line-strong); border-radius: var(--r-box);
  background: var(--white);
}
.auth-restore p { margin: 0; font-size: 13.5px; color: var(--ink); }
.auth-restore .auth-hint { color: var(--ink-faint); }
.auth-card code {
  font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px;
  padding: 1px 5px; border: 1px solid var(--line); border-radius: var(--r-box);
  background: var(--white);
}

@media (max-width: 480px) {
  .auth { padding-top: 28px; }
  .auth-card h1 { font-size: 26px; }
}

/* ===========================================================================
   PHASE6 (2026-09-04) — Instagram's door. The wall on the left, the card on
   the right, a footer of quiet links. Nick: "Follow instagram where it has its
   icon, and photos with the main login on the very right … to make it feel
   more friendly."
   =========================================================================== */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 440px);
  /* The original `.auth` rule centres its items; a centred aside shrinks to
     its copy's width and clips the wall at that edge. Stretch both axes. */
  align-items: stretch; align-content: stretch; justify-items: stretch;
  min-height: 100dvh; padding: 0;
  background: var(--paper);
  overflow: hidden;
}
.auth-show { width: 100%; min-width: 0; }
.auth-body {
  width: auto; min-width: 0;
  display: grid; grid-template-rows: 1fr auto; align-items: center; justify-items: center;
  padding: clamp(24px, 6vh, 64px) clamp(20px, 4vw, 56px) 20px;
  border-left: 1px solid var(--line);
  background: var(--white);
}
.auth-card { width: min(360px, 100%); align-self: center; }

/* the wall */
.auth-show {
  position: relative; isolation: isolate; overflow: hidden;
  background:
    radial-gradient(60% 50% at 20% 90%, rgba(139, 31, 209, 0.16), transparent 70%),
    var(--paper);
}
.auth-wall {
  position: absolute; inset: -14% -26% -18% 22%;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  transform: perspective(1400px) rotateY(-14deg) rotateX(6deg);
  transform-origin: 70% 50%;
  z-index: 0; pointer-events: none;
}
.auth-wall-col {
  display: grid; gap: 16px; align-content: start;
  animation: auth-drift 46s ease-in-out infinite alternate;
  animation-delay: calc(var(--i, 0) * -9s);
}
.auth-wall-col:nth-child(2) { margin-top: -140px; animation-direction: alternate-reverse; }
.auth-wall-col:nth-child(3) { margin-top: -50px; }
.auth-wall-col:nth-child(4) { margin-top: -180px; animation-direction: alternate-reverse; }
.auth-cover {
  display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 30px 60px -22px rgba(36, 20, 46, 0.55);
  background: var(--paper-deep);
}
.auth-wall-col:nth-child(odd) .auth-cover:nth-child(3n) { aspect-ratio: 2 / 3; }
.auth-wall-col:nth-child(even) .auth-cover:nth-child(3n+1) { aspect-ratio: 2 / 3; }
@keyframes auth-drift { from { transform: translateY(0); } to { transform: translateY(-160px); } }

/* the fade that makes it a background rather than a page */
.auth-veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    linear-gradient(90deg, var(--paper) 0%, var(--paper) 14%, rgba(245, 240, 232, 0.92) 32%, rgba(245, 240, 232, 0.42) 62%, rgba(245, 240, 232, 0.62) 100%),
    linear-gradient(180deg, rgba(245, 240, 232, 0.7) 0%, transparent 28%, transparent 64%, var(--paper) 100%);
}
.auth-show-copy {
  position: relative; z-index: 2;
  display: grid; align-content: start; gap: 18px;
  padding: clamp(28px, 4vw, 48px) clamp(28px, 5vw, 72px);
  max-width: 34em;
}
.auth-show-mark { width: 48px; height: 48px; display: block; margin-bottom: clamp(24px, 8vh, 96px); }
.auth-show-h {
  margin: 0; font-family: var(--font-serif);
  font-size: clamp(38px, 4.6vw, 64px); line-height: 1.02; font-weight: 500;
  letter-spacing: -0.02em; color: var(--ink);
}
.auth-show-h em { font-style: italic; color: var(--violet); }
.auth-show-p { margin: 0; font-size: clamp(16px, 1.4vw, 19px); line-height: 1.5; color: var(--ink-soft); max-width: 26em; }

/* the footer */
.auth-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 18px;
  padding: 24px 0 0; font-size: 12px; color: var(--ink-faint);
}
.auth-foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; }
.auth-foot a { color: var(--ink-faint); }
.auth-foot a:hover { color: var(--ink); text-decoration: underline; }

@media (max-width: 1100px) {
  .auth { grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); }
  .auth-wall { inset: -10% -24% -12% 10%; opacity: .7; }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-show { display: none; }
  .auth-body { border-left: 0; padding: clamp(28px, 8vh, 72px) 16px 24px; background: var(--paper); }
}
@media (prefers-reduced-motion: reduce) { .auth-wall-col { animation: none; } }

/* ---------------------------------------------------------------- the gate ---
   13.2 (answer 2), 2026-09-08. Signed out is a CARD OVER THE LIVE FEED, never
   a wall: `#gate` is a fixed layer above the app with NO pointer events of its
   own, so the feed underneath still scrolls, and `.auth-dim` only shades it.
   Only the card and the bar take clicks.

   "Browse first" collapses the card into `.auth-bar` — one line and two ways
   in, pinned to the bottom, above the mobile rail. That bar is what anonymous
   mode looks like; there is no third screen.
   --------------------------------------------------------------------------- */
#gate { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
#gate:empty { display: none; }

.auth-gate { position: absolute; inset: 0; display: grid; }
.auth-gate.is-card {
  align-content: center; justify-items: center;
  padding: clamp(20px, 5vh, 64px) 16px;
  overflow: auto;
  /* The card scrolls with its own layer when it is taller than the viewport;
     the feed behind still takes the wheel everywhere else. */
  pointer-events: none;
}
.auth-dim {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--paper) 72%, transparent);
  backdrop-filter: blur(3px) saturate(85%);
  pointer-events: none;
}
.auth-gate.is-card .auth-body {
  position: relative;
  width: min(400px, 100%);
  pointer-events: auto;
  padding: 26px 26px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(20, 12, 34, .16);
}

/* 19.2 (`anonymous-mode/SPEC.md` entry 4) — AND IT NEVER COVERS ☰ More.
   Nick, with inspect element: "the footer was blocking the '3-line' settings
   at the bottom." The bar is pinned to the bottom of a layer that spans the
   whole viewport, and on a desktop the bottom-left of the viewport is where
   the rail keeps More. So the bar starts where the rail ends — the same two
   widths `ig.css` sets the grid at. (A phone rail is the bottom tab bar, and
   the bar already sits above it.) */
.auth-gate.is-bar { align-content: end; }
@media (min-width: 901px) { .auth-gate.is-bar { left: 244px; } }
@media (min-width: 901px) and (max-width: 1263px) { .auth-gate.is-bar { left: 72px; } }
.auth-bar {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  width: 100%; box-sizing: border-box;
  padding: 12px clamp(14px, 4vw, 28px);
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(20, 12, 34, .10);
}
.auth-bar-mark { flex: none; display: block; }
.auth-bar-line { flex: 1 1 auto; margin: 0; font-size: 13.5px; color: var(--ink-soft); }
.auth-bar-sub { color: var(--ink-faint); }
.auth-bar-acts { flex: none; display: flex; gap: 8px; }
.auth-btn.is-small { padding: 8px 14px; font-size: 13px; width: auto; }

/* 14.8 (_global/mobile/SPEC.md entry 3) — THE BOTTOM OF A PHONE SCREEN.
   "The tab bar is always there — signed in or not"; the account bar "becomes
   a slim one-line strip above the tab bar", covering neither the tab bar nor
   the composer nor a bottom sheet's actions. It used to sit ON the bottom
   edge, which is where the tab bar lives, so an anonymous visitor had no menu
   at all — Nick: "Where is menus on the mobile? Cant even see that.."

   `--tabbar-h` is the phone tab bar's own height (app.css sets the same
   numbers); everything that has to clear the bottom reads it. */
@media (max-width: 900px) {
  .auth-gate.is-bar { bottom: var(--tabbar-h, 64px); top: auto; height: auto; }
  .auth-bar {
    flex-wrap: nowrap; gap: 8px; padding: 7px 10px;
    border-bottom: 1px solid var(--line);
  }
  .auth-bar-mark { width: 18px; height: 18px; }
  .auth-bar-line { flex: 1 1 auto; min-width: 0; font-size: 11.5px; line-height: 1.25;
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* one line means one claim: the subtitle is the desktop's */
  .auth-bar-sub { display: none; }
  .auth-bar-acts { flex: none; gap: 6px; }
  .auth-bar-acts .auth-btn.is-small { padding: 6px 10px; font-size: 12px; }
}

/* 21.6 (public-profile/SPEC.md 6) — the login card as a real modal: the page
   under it is fixed in place, a press on the dim closes it (= Browse first,
   onboarding.js), and it fades out rather than vanishing (AUTH_FADE_MS). */
html.gate-locked, html.gate-locked body, html.gate-locked .surface { overflow: hidden; }
.auth-gate.is-card .auth-dim { pointer-events: auto; cursor: pointer; }
.auth-gate.is-card.is-leaving { animation: auth-out 200ms cubic-bezier(.4,0,.6,1) forwards; pointer-events: none; }
.auth-gate.is-card.is-leaving .auth-body { pointer-events: none; }
@keyframes auth-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .auth-gate.is-card.is-leaving { animation-duration: 1ms; } }

/* 2026-09-14 — ON A PHONE THE DOOR FILLS THE SCREEN (Nick: "as simple as
   instagrams … Full encapsulation"). The card is the page: no dim, no
   half-height sheet, the mark on top, the footer of links at the bottom. */
@media (max-width: 900px) {
  .auth-gate:not(.is-bar) .auth-dim { display: none; }
  .auth-gate:not(.is-bar) .auth-body {
    /* 2026-09-15 — `width: min(400px, 100%)` is the desktop card's; on an
       820px iPad it drew the door as a 400px column down the left with the
       feed showing beside it (tablet photo). The screen is the width. */
    position: fixed; inset: 0; width: auto; z-index: 70; border: 0; border-radius: 0;
    grid-template-rows: 1fr auto; padding: 48px 24px 20px; overflow: auto;
    background: var(--white);
  }
  .auth-gate:not(.is-bar) .auth-card { width: min(340px, 100%); }
  .auth-gate:not(.is-bar) .auth-mark { display: block; margin: 0 auto 24px; height: 34px; }
}

@media (max-width: 720px) {
  .auth-bar { padding: 8px 12px; gap: 8px; box-shadow: none; }
  .auth-bar-line { font-size: 12px; }
  .auth-bar-sub { display: none; }
  .auth-btn.is-small { padding: 7px 10px; font-size: 12px; }
}

@media (max-width: 900px) {
  .auth-gate.is-bar { position: fixed; left: 0; right: 0; top: auto; bottom: calc(57px + env(safe-area-inset-bottom, 0px)); width: 100%; z-index: 39; }
  .auth-bar { width: 100%; }
}
/* 2026-09-15 — and under an open sheet it goes at EVERY width (Nick, Firefox
   on the film page: the footer "shows up over everything"). */
body:has(.mc-scrim) .auth-gate.is-bar, body:has(.ig-scrim) .auth-gate.is-bar, body:has(.ch-pop-scrim) .auth-gate.is-bar { display: none; }
@media (max-width: 900px) { .auth-gate:not(.is-bar) .auth-foot { display: none; } }
