/* Badge landing. Night sky, type and top bar taken from recordsapp.org (Inter,
   #050a1c, stars from sky.js). The page itself is only the mark and the word Badge. */

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/inter-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/inter-latin-600-normal.woff2") format("woff2");
}

@property --theme-t { syntax: "<number>"; inherits: true; initial-value: 0; }

:root, html {
  --hdr-h: 65px;
  --theme-fade-duration: .6s;
  --theme-fade-easing: ease;
  --theme-t: 0;
  --text-t: calc(var(--theme-t) * var(--theme-t) * (2 - var(--theme-t)));
  /* Same mix as the docs page: #fbfaf5 ↔ #0f0e0d. */
  --bg: color-mix(in oklab, #fbfaf5 calc((1 - var(--theme-t)) * 100%), #0f0e0d calc(var(--theme-t) * 100%));
  --ink: color-mix(in srgb, #1d1f24 calc((1 - var(--text-t)) * 100%), #ffffff calc(var(--text-t) * 100%));
  --text: color-mix(in srgb, #374151 calc((1 - var(--text-t)) * 100%), #bdbdbd calc(var(--text-t) * 100%));
  --quiet: color-mix(in srgb, #5c5f66 calc((1 - var(--text-t)) * 100%), #a3a3a3 calc(var(--text-t) * 100%));
  --line: color-mix(in oklab, #f2f2f2 calc((1 - var(--theme-t)) * 100%), #2a2a2a calc(var(--theme-t) * 100%));
  --accent: #1f6fe5;
  --muted: var(--quiet);
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --theme-t: 1;
  --accent: #64b5f6;
}

/* Browsers without color-mix still get the two end palettes, without the fade. */
@supports not (background: color-mix(in oklab, #fbfaf5, #0f0e0d)) {
  :root, html {
    --bg: #fbfaf5;
    --ink: #1d1f24;
    --text: #374151;
    --quiet: #5c5f66;
    --line: #f2f2f2;
  }
  html[data-theme="dark"] {
    --bg: #0f0e0d;
    --ink: #ffffff;
    --text: #bdbdbd;
    --quiet: #a3a3a3;
    --line: #2a2a2a;
  }
}

html.theme-fade {
  transition:
    --theme-t var(--theme-fade-duration) var(--theme-fade-easing),
    --accent var(--theme-fade-duration) var(--theme-fade-easing);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.028em;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

html.has-sky, html.has-sky body {
  background-color: var(--bg);
}

/* --- Records sky.js stars (night). Exact rules from recordsapp.org/static/css/app.css. --- */
.lp-stars {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--sky-h, 100lvh);
  overflow: hidden;
  pointer-events: none;
  contain: strict;
  transform: translateZ(0);
}

.lp-stars span {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: lp-drift var(--drift) ease-in-out var(--drift-delay) infinite alternate;
}

.lp-stars .is-bright {
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.7);
}

.lp-stars .is-twinkle {
  animation:
    lp-drift var(--drift) ease-in-out var(--drift-delay) infinite alternate,
    lp-twinkle var(--twinkle) ease-in-out var(--twinkle-delay) infinite;
}

@keyframes lp-drift {
  from { translate: 0 0; }
  to { translate: var(--dx) var(--dy); }
}

@keyframes lp-twinkle {
  0%, 100% { scale: 1; opacity: var(--o); }
  50% { scale: 0.6; opacity: calc(var(--o) * 0.25); }
}

@media (prefers-reduced-motion: reduce) {
  .lp-stars span,
  .lp-stars .is-twinkle {
    animation: none;
  }
}

html.is-scrolling .lp-stars,
html.is-scrolling .lp-stars * {
  animation-play-state: paused !important;
}

/* --- Top bar, sized and set like Records' header.rv-ph --- */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  height: var(--hdr-h);
  min-height: var(--hdr-h);
  padding: 0 16px;
  padding-top: env(safe-area-inset-top, 0px);
  background: none;
  pointer-events: none;
}

/* Theme toggle: same control as raineyshah.com, top right. Lives outside #gate so it
   stays on the signed-in profile. No bar: the header stays pinned but is transparent
   and passes clicks through, so it never crops content; only the icon sits top right. */
.header-actions {
  pointer-events: auto;
  flex: none;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0;
}
.header-action,
button.theme-toggle.header-action {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--quiet);
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none !important;
  box-sizing: border-box;
}
.theme-toggle svg,
.theme-toggle__icon {
  display: block;
  width: 32px;
  height: 32px;
  color: var(--quiet);
  overflow: visible;
}
.header-action:hover { opacity: .85; }
.header-action:focus { outline: none; }
.header-action:focus-visible { outline: 2px solid var(--quiet); outline-offset: 2px; }
/* Like /develop and /use: the sun/moon turns the accent gold on hover and while pressed. Every part of
   the icon is drawn in --quiet, so the button re-points --quiet at the accent for itself only. */
.theme-toggle { --accent: #956c25; }
html[data-theme="dark"] .theme-toggle { --accent: #dcc28e; }
.theme-toggle:hover, .theme-toggle:active { --quiet: var(--accent); opacity: 1; }

/* Sun (light) morphs to a crescent moon (dark), driven by --theme-t. */
.theme-toggle__disc {
  transform-origin: 12px 12px;
  transform: scale(0.42);
  fill: var(--quiet);
  fill-opacity: var(--theme-t);
  stroke: var(--quiet);
  stroke-width: 2;
}
.theme-toggle__cut {
  transform-origin: 12px 12px;
  transform: translate(10px, -10px);
}
.theme-toggle__rays {
  fill: none !important;
  stroke: var(--quiet);
  stroke-width: 1.5;
  transform-origin: 12px 12px;
  transform: scale(0.56) rotate(0deg);
  opacity: 1;
}
.theme-toggle__rays-hole {
  transform-origin: 12px 12px;
  transform: scale(1);
}
html.theme-fade .theme-toggle__disc {
  transition:
    transform var(--theme-fade-duration) var(--theme-fade-easing),
    stroke-width var(--theme-fade-duration) var(--theme-fade-easing);
}
html.theme-fade .theme-toggle__cut {
  transition: transform var(--theme-fade-duration) var(--theme-fade-easing);
}
html.theme-fade .theme-toggle__rays {
  transition: transform var(--theme-fade-duration) var(--theme-fade-easing), opacity var(--theme-fade-duration) var(--theme-fade-easing);
}
html.theme-fade .theme-toggle__rays-hole {
  transition: transform var(--theme-fade-duration) var(--theme-fade-easing);
}
html[data-theme="dark"] .theme-toggle__disc {
  transform: scale(1);
  fill: var(--quiet);
  stroke: var(--quiet);
  stroke-width: 0;
}
html[data-theme="dark"] .theme-toggle__cut {
  transform: translate(3.2px, -3.6px);
}
html[data-theme="dark"] .theme-toggle__rays {
  transform: scale(.35) rotate(90deg);
  opacity: 0;
}
html[data-theme="dark"] .theme-toggle__rays-hole {
  transform: scale(2);
}
@media (prefers-reduced-motion: reduce) {
  html.theme-fade,
  .theme-toggle__disc,
  .theme-toggle__cut,
  .theme-toggle__rays,
  .theme-toggle__rays-hole {
    transition: none;
  }
}


/* --- Centered silver badge --- */
main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh; /* the visible height (100lvh was taller than the screen on iOS, so it scrolled) */
  padding-bottom: 16vh; /* centres the badge, button and links a little above the middle */
  box-sizing: border-box;
}

.badge {
  position: relative;
  width: min(440px, 88vw);
  height: min(440px, 88vw);
  display: grid;
  place-items: center;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.badge.is-dragging { cursor: grabbing; }

.badge__shadow {
  position: absolute;
  left: 50%;
  bottom: 18%;
  width: 58%;
  height: 16%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.12), transparent 70%);
  filter: blur(12px);
  pointer-events: none;
}

.badge__stage {
  position: relative;
  width: 62%;
  height: 62%;
  perspective: 1200px;
  perspective-origin: 50% 48%;
  z-index: 2;
}

.badge__rig,
.badge__stack {
  transform-style: preserve-3d;
}

.badge__rig {
  width: 100%;
  height: 100%;
  will-change: transform;
}

.badge__stack {
  position: relative;
  width: 100%;
  height: 100%;
}

.badge__face,
.badge__wall {
  position: absolute;
  pointer-events: none;
}

.badge__face {
  inset: 0;
}

.badge__wall {
  /* The logo's border colour, so the side runs flush on from the face's outline. */
  background: #c9bd8d;
  box-shadow: 0 0 0 1px #c9bd8d;
  backface-visibility: hidden; /* only the walls facing you draw (see landing.js) */
  -webkit-backface-visibility: hidden;
}

.badge__face {
  /* Flat and isolated: the light streak's blend stays inside this one face instead of making the
     browser re-composite the whole 3D stack every frame (that flickered and loaded the GPU). */
  transform-style: flat;
  isolation: isolate;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.badge__face img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Glimmer on the front face, as on the popup badge: an oversized tilted streak slid across by a CSS
   animation of its transform alone (no per-frame script, no repaint). Clipped to the badge's shape. */
.badge__gleam {
  position: absolute;
  inset: 4%;
  border-radius: 21.74%;
  overflow: hidden;
  /* iOS WebKit ignores rounded overflow on a composited 3D layer; clip-path and a same-radius mask keep the 3x streak inside the tile. */
  -webkit-clip-path: inset(0 round 21.74%);
  clip-path: inset(0 round 21.74%);
  -webkit-mask-image: url("/landing/assets/badge-face-mask.svg");
  -webkit-mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-image: url("/landing/assets/badge-face-mask.svg");
  mask-size: 100% 100%;
  mask-repeat: no-repeat;
  pointer-events: none;
}

.badge__gleam i,
.badge__gleam i::after {
  position: absolute;
  inset: -100%; /* 3x the face, so the tilted streak spans it corner to corner */
}

.badge__gleam i {
  background: linear-gradient(90deg, transparent 0%, transparent 42.7%, rgba(255, 255, 255, 0.06) 46.7%,
    rgba(255, 255, 255, 0.22) 49%, rgba(255, 255, 255, 0.85) 50%, rgba(255, 255, 255, 0.18) 51.3%,
    transparent 54.7%, transparent 100%);
  mix-blend-mode: soft-light;
  opacity: 0.9;
  transform: rotate(28deg) translateX(-26%);
  will-change: transform;
  animation: badge-sweep 3s linear infinite;
}

.badge__gleam i::after {
  content: "";
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, transparent 48.3%, rgba(255, 255, 255, 0.55) 50%,
    transparent 51.7%, transparent 100%);
  mix-blend-mode: overlay;
  opacity: 0.75;
}

/* The back face is turned around, so its streak is mirrored back: seen from behind it runs left to
   right at the same tilt as the front. */
.badge__gleam--back { transform: scaleX(-1); }

/* 1.1 s across, then off the right edge for 1.9 s; the jump back happens out of sight. */
@keyframes badge-sweep {
  0% { transform: rotate(28deg) translateX(-26%); }
  36.7%, 100% { transform: rotate(28deg) translateX(26%); }
}

@media (prefers-reduced-motion: reduce) {
  .badge__gleam i { animation: none; transform: rotate(28deg) translateX(-8%); will-change: auto; }
}

@media (max-width: 520px) {
  .badge { width: min(380px, 94vw); height: min(380px, 94vw); }
  .badge__stage { width: 68%; height: 68%; }
}

/* --- Enter button under the line: Vanilla's Standalone button (class vn-button vn-button--standalone, vanilla/components/buttons.css); only its place is set here --- */
.enter {
  position: relative;
  z-index: 2;
  margin-top: 22px;
}

.gate-error {
  position: relative;
  z-index: 2;
  max-width: 320px;
  margin: 12px 0 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.4;
  color: #9a3412;
}

#profile { display: none; }
html.is-unlocked #gate { display: none; }
/* The front page doesn't scroll (or rubber-band on iOS); the signed-in profile on this same page does. */
/* No rubber-band bounce on the badge page either: the fixed header stays put. */
html, body { overscroll-behavior-y: none; }
html:not(.is-unlocked), html:not(.is-unlocked) body { height: 100%; overflow: hidden; overscroll-behavior: none; }
/* The unlocked profile is styled by landing/profile/profile.css. */
html.is-unlocked #profile { display: block; min-height: 100dvh; }
/* Signed in: the header spans the same 560px column as the profile (.pf), so the sun/moon icon's
   right edge lines up with the right edge of the menus. .pf pads 16px; the 32px icon sits 6px
   inside its 44px button, so the header pads 10px. */
html.is-unlocked header {
  left: 50%;
  right: auto;
  width: min(560px, 100%);
  transform: translateX(-50%);
  padding-right: 10px;
}

@media (prefers-reduced-motion: reduce) {
  .links a { transition: none; }
}

/* The line under the badge, with the button underneath it. The pull-up is the space the button used to close under the badge. */
.quote {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  width: min(36em, calc(100% - 48px));
  margin: -36px 0 0;
  color: var(--quiet);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.015em;
  text-align: center;
  text-wrap: pretty;
}
.quote a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: currentColor;
  text-decoration-skip-ink: none;
}
.quote p { margin: 0; }

/* --- Quiet text links under the button --- */
.links {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 18px;
}
.links a {
  color: var(--quiet);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  text-decoration: none;
  text-underline-offset: 3px;
  transition: color 0.18s ease;
}
.links a:hover {
  color: var(--ink);
}
.links a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 3px;
}

/* White page: no star field. */
.lp-stars { display: none; }


/* Gate: create / recover (below the main button) */
/* Access popup: the three options as plain text at the bottom, the recovery form inside. */
.gate-dialog .pf-qrbox { width: min(344px, 92vw); }
.gate-dialog .gate-alt { justify-content: center; gap: 8px; margin-top: 18px; white-space: nowrap; }
.gate-dialog .pf-qrbox .gate-link { margin: 0; min-width: 0; height: auto; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none;
  color: #5c5f66; font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1.4; transform: none; filter: none; }
.gate-dialog .pf-qrbox .gate-link:hover { color: #2a2c31; }
.gate-dialog .pf-qrbox .gate-link[aria-pressed="true"] { color: #1d1f24; font-weight: 600; text-decoration: underline; }
.gate-dialog #existing-form { margin-top: 4px; }
.gate-dialog .gate-recover { width: 100%; margin-top: 14px; }
.gate-dialog .gate-recover button { margin-top: 4px; width: 100%; border-radius: 12px; } /* as wide as, and as round as, the inputs; Field like Access your Badge */
/* Fields (username, the 12 words) are Vanilla's: vanilla/components/fields.css. */
.gate-dialog .pf-pop-body .gate-error { margin: 12px 0 0; color: #b42318; }
.gate-dialog .pf-pop-body .gate-name-status { margin: 0; font-size: 13px; line-height: 1.4; color: var(--pf-muted); word-break: normal; }
.gate-dialog .pf-pop-body .gate-name-status[hidden] { display: none; }
.gate-name-status[data-kind="ok"] { color: #1a7f37 !important; }
.gate-name-status[data-kind="bad"] { color: #b42318 !important; }
.gate-dialog .gate-recover button:disabled { opacity: .45; cursor: default; transform: none; filter: none; }
.gate-alt { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; margin-top: 14px; color: #8a8d93; font-size: 13px; }
.gate-link { border: 0; padding: 0; background: none; font: inherit; font-weight: 500; color: #5c5f66; cursor: pointer; text-underline-offset: 3px; }
.gate-link:hover { color: #2a2c31; }
.gate-link:focus-visible { outline: 2px solid #2a2c31; outline-offset: 3px; border-radius: 4px; }
.gate-link:disabled { opacity: .5; cursor: default; text-decoration: none; }
.gate-recover { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(340px, 100%); margin-top: 16px; }
.gate-recover[hidden] { display: none; }
.gate-hint { margin: 0; font-size: 12px; color: #8a8d93; text-align: center; }
.enter.enter-small { margin-top: 4px; height: 40px; font-size: 15px; }

/* BADGE-025: framed (js/frameguard.js). The access popup is removed; this is all that shows. */
html[data-framed] #access-dialog, html[data-framed] #profile { display: none !important; }
.framed-notice { display: grid; gap: 10px; place-items: center; min-height: 60vh; text-align: center; font-size: 15px; }
.framed-notice p { margin: 0; }
.framed-notice a { font-weight: 600; color: inherit; }

/* The badge opens only in this browser until its passkey wrap is saved to Arweave (landing/shell.js). */
.local-only-notice { display: none; box-sizing: border-box; max-width: 560px; margin: 12px auto 0; padding: 10px 14px; border: 1px solid #f2c94c; border-radius: 12px;
  background: #fff8e1; color: #7a4b00; font: 13px/1.45 Inter, system-ui, sans-serif; text-align: center; }
html.is-unlocked .local-only-notice:not([hidden]) { display: block; }

/* Access popup buttons: a soft ring for keyboard focus only (js/softfocus.js keeps mouse and touch opens off
 * the button). Safari otherwise drew a thick ring around Use passkey as the popup opened. */
.gate-dialog .pf-qrbox button:focus:not(:focus-visible) { outline: none; }
.gate-dialog .pf-qrbox button:focus-visible { outline: 2px solid rgba(42, 44, 49, .35); outline-offset: 2px; }
.gate-dialog:focus, .gate-dialog:focus-visible { outline: none; }

/* Dark theme: landing gate, links, access popup, and the badge's floor shadow.
   The signed-in profile's dark tokens live in profile.css (html[data-theme="dark"] --pf-*). */
/* Access your Badge and the popup actions follow the Standalone tokens (profile.css), so they need no dark rules here. */
html[data-theme="dark"] .gate-dialog .gate-recover button:disabled {
  opacity: 0.45;
  cursor: default;
  filter: none;
  transform: none;
}
html[data-theme="dark"] .badge__shadow {
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08), transparent 70%);
}
html[data-theme="dark"] .gate-dialog { color: #ffffff; }
html[data-theme="dark"] .gate-dialog .pf-qrbox {
  background: #161616;
  color: #ffffff;
  box-shadow: inset 0 0 0 1px #2a2a2a;
}
html[data-theme="dark"] .gate-dialog .pf-qrbox h2 { color: #ffffff; }
html[data-theme="dark"] .gate-dialog .pf-pop-body p,
html[data-theme="dark"] .gate-dialog #access-text { color: #bdbdbd; }
html[data-theme="dark"] .gate-dialog .pf-x { color: #a3a3a3; }
html[data-theme="dark"] .gate-dialog .pf-x:hover { background: rgba(255, 255, 255, .08) !important; color: #ffffff !important; }
html[data-theme="dark"] .gate-dialog .pf-qrbox .gate-link { color: #a3a3a3; }
html[data-theme="dark"] .gate-dialog .pf-qrbox .gate-link:hover { color: #ffffff; }
html[data-theme="dark"] .gate-dialog .pf-qrbox .gate-link[aria-pressed="true"] { color: #ffffff; }
html[data-theme="dark"] .gate-alt { color: #a3a3a3; }
html[data-theme="dark"] .gate-error,
html[data-theme="dark"] .gate-dialog .pf-pop-body .gate-error { color: #f2b8b5; }

/* Upside down (landing.js adds .is-upside): the picture turns so it still reads the right way up. */
.badge.is-upside .badge__face img { transform: rotate(180deg); }

/* The sun/moon is Vanilla's <vn-theme-toggle>; its wrapper adds no box, so the button sits as before. */
vn-theme-toggle { display: contents; }
