/* ============================================================
   Nara NFC cards
   Liquid glass over a lit backdrop. Phone-first, one screen, ten seconds.
   ============================================================ */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('fonts/archivo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('fonts/archivo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Martian Mono';
  font-style: normal;
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
  src: url('fonts/martianmono-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- tokens ---------- */

:root {
  --ink: #070a12;
  --stamp: #f2f0ea;
  --muted: #9aa4b8;
  --rule: rgba(255, 255, 255, 0.09);

  --foil-1: #f7e3ae;
  --foil-2: #d5a851;
  --foil-3: #94702a;
  --glow: 213, 168, 81; /* the accent as raw channels, for rgba() mixes */
  --foil-line: linear-gradient(101deg, var(--foil-3), var(--foil-1) 42%, var(--foil-2) 68%, var(--foil-3));

  /* Glass material */
  --glass-tint: rgba(255, 255, 255, 0.12);
  --glass-tint-2: rgba(255, 255, 255, 0.045);
  --glass-blur: 26px;

  --display: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Martian Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --shell: 25.5rem;
  --gutter: 1.35rem;
  --radius: 22px;

  --ease: cubic-bezier(0.22, 0.68, 0.24, 1);
}

/* The studio card stamps in cool nickel rather than warm brass. */
[data-theme='steel'] {
  --foil-1: #eef3fa;
  --foil-2: #aebed3;
  --foil-3: #6c7f97;
  --glow: 174, 190, 211;
}

/* ---------- base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  /* Centres a short card on a tall phone. `safe` matters: plain centring
     would push the top of an overflowing page out of reach of the scroller. */
  display: grid;
  align-content: center;
  align-content: safe center;
  background: var(--ink);
  color: var(--stamp);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Glass needs something worth refracting. These are the lights behind it —
   fixed, so the panels keep catching them while the page scrolls. */
body::before {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  /* Positioned so the strongest light lands behind the card itself — glass
     over an unlit patch of backdrop is just a grey box. */
  background:
    radial-gradient(52% 34% at 30% 16%, rgba(var(--glow), 0.92), transparent 68%),
    radial-gradient(40% 30% at 90% 12%, rgba(104, 142, 240, 0.78), transparent 68%),
    radial-gradient(46% 26% at 66% 30%, rgba(196, 108, 190, 0.32), transparent 70%),
    radial-gradient(44% 34% at 74% 72%, rgba(42, 194, 196, 0.62), transparent 70%),
    radial-gradient(48% 38% at 10% 80%, rgba(140, 82, 232, 0.66), transparent 72%);
  filter: blur(22px);
  animation: aurora 26s var(--ease) infinite alternate;
}

@keyframes aurora {
  0% {
    transform: translate3d(-2%, -1%, 0) scale(1);
  }
  50% {
    transform: translate3d(3%, 2%, 0) scale(1.09);
  }
  100% {
    transform: translate3d(-1%, 3%, 0) scale(1.03);
  }
}

/* A fine grain over the lights. Without it, wide gradients band on OLED. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: 2px solid var(--foil-1);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ---------- the glass material ----------
   One definition, three surfaces. Everything that floats uses it. */

.glass,
.btn-glass,
.card {
  position: relative;
  isolation: isolate;
  border-radius: var(--radius);
  background: linear-gradient(158deg, var(--glass-tint), var(--glass-tint-2));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.16) inset,
    0 -1px 0 rgba(255, 255, 255, 0.05) inset,
    0 20px 46px -22px rgba(0, 0, 0, 0.85),
    0 2px 10px -4px rgba(0, 0, 0, 0.5);
}

/* The specular rim — bright where the light lands, gone where it doesn't.
   A flat 1px border is what makes glass read as a grey box instead. */
.glass::before,
.btn-glass::before,
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(
    152deg,
    rgba(255, 255, 255, 0.62),
    rgba(255, 255, 255, 0.08) 34%,
    rgba(255, 255, 255, 0) 58%,
    rgba(255, 255, 255, 0.24)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

/* Where the backdrop can't be blurred, lean opaque instead of muddy. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .glass,
  .btn-glass,
  .card {
    background: linear-gradient(158deg, rgba(24, 30, 46, 0.94), rgba(14, 19, 31, 0.94));
  }
}

/* ---------- shell ---------- */

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding:
    max(clamp(1.5rem, 6vw, 2.5rem), env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(2.25rem, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
}

/* ---------- the card object ---------- */

.card-stage {
  perspective: 1100px;
  margin-bottom: 1.5rem;
}

.card {
  aspect-ratio: 1.586;
  padding: clamp(1rem, 4.4vw, 1.3rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 0.5s var(--ease);
  will-change: transform;
}

/* The sheen. --sheen runs 0 -> 1 and sweeps a highlight across the glass.
   Ambient by default; the pointer takes it over on desktop. */
.card::after {
  content: '';
  position: absolute;
  inset: -40%;
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.55;
  background: linear-gradient(
    102deg,
    transparent 32%,
    rgba(255, 255, 255, 0.06) 44%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(255, 255, 255, 0.06) 56%,
    transparent 68%
  );
  transform: translateX(calc((var(--sheen, 0.5) - 0.5) * 128%));
  animation: drift 9s var(--ease) infinite;
}

@keyframes drift {
  0%,
  100% {
    --sheen: 0.12;
  }
  50% {
    --sheen: 0.88;
  }
}

/* Animating a custom property needs it registered, otherwise it snaps
   between keyframes instead of sweeping. */
@property --sheen {
  syntax: '<number>';
  inherits: true;
  initial-value: 0.5;
}

.card > * {
  position: relative;
  z-index: 3;
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

/* A chip rather than bare foil text. What sits behind the glass changes as
   the lights drift, and 10px gradient type loses that fight every time. */
.card-brand {
  padding: 0.3rem 0.6rem 0.26rem;
  border-radius: 999px;
  background: rgba(10, 13, 22, 0.42);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--foil-1);
}

/* The contactless mark. Every NFC card carries it; so does this one. */
.card-nfc {
  flex: none;
  width: 17px;
  height: 21px;
  color: var(--foil-2);
  opacity: 0.9;
}

.card-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.9rem;
  min-width: 0;
}

/* Identity sits at the foot, the way it does on a real card. Anchoring it
   here is also what keeps the middle from reading as dead space. */
.card-foot {
  min-width: 0;
}

.card-name {
  margin: 0;
  font-size: clamp(1.7rem, 8.4vw, 2.35rem);
  font-weight: 800;
  font-variation-settings: 'wdth' 112, 'wght' 800;
  letter-spacing: -0.022em;
  line-height: 0.98;
  background: var(--foil-line);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  overflow-wrap: break-word;
}

.card-role {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(242, 240, 234, 0.78);
}

.card-serial {
  display: block;
  margin-top: 0.66rem;
  font-family: var(--mono);
  font-size: 0.52rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(242, 240, 234, 0.55);
}

/* The portrait, set like the photo on an access badge. */
.card-portrait {
  flex: none;
  width: clamp(4.4rem, 22vw, 5.6rem);
  aspect-ratio: 4 / 5;
  border-radius: 13px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.22) inset,
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 10px 22px -10px rgba(0, 0, 0, 0.8);
}

.card-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* With a portrait alongside it, the name needs less room to itself. */
.card.has-portrait .card-name {
  font-size: clamp(1.45rem, 6.8vw, 1.95rem);
}

/* ---------- tagline ---------- */

.tagline {
  margin: 0 0 1.4rem;
  padding-left: 0.9rem;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.96rem;
  line-height: 1.45;
  color: rgba(242, 240, 234, 0.74);
  text-wrap: pretty;
}

/* ---------- actions ---------- */

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 3.5rem;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 16px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 650;
  font-variation-settings: 'wdth' 104, 'wght' 650;
  color: var(--stamp);
  cursor: pointer;
  transition: transform 0.16s var(--ease), filter 0.16s var(--ease);
}

.btn svg {
  flex: none;
  width: 17px;
  height: 17px;
}

/* The one solid surface on the page. Glass everywhere would leave the
   primary action with nothing to be more solid than. */
.btn-save {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  color: #1b1405;
  background: linear-gradient(140deg, var(--foil-1), var(--foil-2) 56%, var(--foil-3));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 -1px 0 rgba(0, 0, 0, 0.14) inset,
    0 14px 30px -14px rgba(var(--glow), 0.75);
}

.btn-save::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent 58%);
}

/* Splits evenly with two buttons, fills the row with one. Flex rather than
   auto-fit grid, which collapses to a single track against a 0 minimum. */
.btn-pair {
  display: flex;
  gap: 0.6rem;
}

.btn-pair .btn {
  flex: 1 1 0;
  min-width: 0;
}

.btn:active {
  transform: scale(0.985);
}

@media (hover: hover) {
  .btn-save:hover {
    filter: brightness(1.06);
  }
  .btn-glass:hover {
    filter: brightness(1.25);
  }
}

/* ---------- links ---------- */

.rail-label {
  display: block;
  margin-bottom: 0.65rem;
  padding-left: 0.15rem;
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 400;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--muted);
}

.links {
  list-style: none;
  margin: 0 0 1.9rem;
  padding: 0.3rem 0.35rem;
  overflow: hidden;
}

.links li + li {
  border-top: 1px solid var(--rule);
}

.link-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 3.35rem;
  padding: 0.5rem 0.6rem;
  border-radius: 13px;
  transition: background-color 0.2s var(--ease);
}

.link-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.14) inset;
}

.link-icon svg {
  width: 15px;
  height: 15px;
  color: var(--foil-1);
}

.link-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.96rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-arrow {
  flex: none;
  display: grid;
  place-items: center;
  transition: transform 0.2s var(--ease), color 0.2s var(--ease);
}

.link-arrow svg {
  width: 11px;
  height: 11px;
  color: var(--muted);
}

@media (hover: hover) {
  .link-row:hover {
    background: rgba(255, 255, 255, 0.07);
  }
  .link-row:hover .link-arrow {
    transform: translate(2px, -2px);
  }
  .link-row:hover .link-arrow svg {
    color: var(--foil-1);
  }
}

/* ---------- footer ---------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(154, 164, 184, 0.8);
}

.foot a {
  transition: color 0.2s var(--ease);
}

@media (hover: hover) {
  .foot a:hover {
    color: var(--stamp);
  }
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  /* Clear the viewport by the toast's own height plus its offset, so it can
     never peek above the fold before it is called. */
  transform: translate(-50%, calc(100% + 2.5rem));
  transition: transform 0.42s var(--ease);
}

.toast[data-open='true'] {
  transform: translate(-50%, 0);
}

.toast svg {
  width: 15px;
  height: 15px;
  color: var(--foil-1);
}

/* ---------- directory ---------- */

.dir-head {
  margin-bottom: 1.6rem;
}

.dir-title {
  margin: 0.5rem 0 0.4rem;
  font-size: clamp(2rem, 10vw, 2.6rem);
  font-weight: 800;
  font-variation-settings: 'wdth' 112, 'wght' 800;
  letter-spacing: -0.022em;
  line-height: 1;
  background: var(--foil-line);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.dir-blurb {
  margin: 0;
  font-size: 0.96rem;
  color: rgba(242, 240, 234, 0.68);
  text-wrap: pretty;
}

.dir-list {
  list-style: none;
  margin: 0 0 1.9rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.dir-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  transition: transform 0.2s var(--ease), filter 0.2s var(--ease);
}

.dir-thumb {
  flex: none;
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 13px;
  object-fit: cover;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18) inset,
    0 1px 0 rgba(255, 255, 255, 0.3) inset;
}

.dir-thumb-blank {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.07);
  font-size: 1.25rem;
  font-weight: 700;
  font-variation-settings: 'wdth' 108, 'wght' 700;
  background-image: var(--foil-line);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.dir-body {
  flex: 1 1 auto;
  min-width: 0;
}

.dir-serial {
  display: block;
  margin-bottom: 0.2rem;
  font-family: var(--mono);
  font-size: 0.5rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.dir-name {
  display: block;
  font-size: 1.14rem;
  font-weight: 700;
  font-variation-settings: 'wdth' 108, 'wght' 700;
  letter-spacing: -0.012em;
}

.dir-role {
  display: block;
  font-size: 0.83rem;
  color: rgba(242, 240, 234, 0.62);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (hover: hover) {
  .dir-card:hover {
    transform: translateY(-2px);
    filter: brightness(1.18);
  }
}

/* ---------- load sequence: the card sets, then the rest follows ---------- */

.rise {
  opacity: 0;
  transform: translateY(9px);
  animation: rise 0.62s var(--ease) forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes rise {
  to {
    opacity: 1;
    transform: none;
  }
}

.card-stage {
  opacity: 0;
  transform: scale(0.955);
  animation: stamp 0.72s var(--ease) forwards;
}

@keyframes stamp {
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .card-stage,
  .rise {
    opacity: 1;
    transform: none;
  }
  .card {
    transform: none !important;
  }
}
