/* Ask Key — "How it works" section. Everything is scoped under .akhw so it
   can sit inside the existing site without touching its styles. */

@font-face {
  font-family: "Hanken Grotesk";
  src: url("/fonts/HankenGrotesk-Variable.woff2") format("woff2");
  font-weight: 200 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/IBMPlexMono-Regular-Latin1.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Standalone page chrome (not needed when embedded in the site). */
.akhw-page {
  margin: 0;
  background: #fff;
  color: #1a1a1a;
  font-family: "Hanken Grotesk", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", system-ui, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.akhw-bar, .akhw-foot {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 28px clamp(24px, 4.5vw, 64px);
  font-size: 13.5px;
  color: #6e6e6e;
}
.akhw-bar a, .akhw-foot a { color: inherit; text-decoration: none; }
.akhw-bar a:hover, .akhw-foot a:hover { color: #1a1a1a; }
.akhw-brand { display: flex; align-items: center; gap: 10px; margin-right: auto; color: #1a1a1a !important; font-weight: 400; }
.akhw-foot { justify-content: space-between; margin-top: 120px; border-top: 1px solid #e7e7e7; font-size: 12.5px; color: #9a9a9a; }

/* Section */

.akhw {
  --ink: #1a1a1a;
  --gray: #6e6e6e;
  --soft: #a1a1a6;
  --faint: #9a9a9a;
  --line: #e7e7e7;
  --zhu: #b8281e;
  --gutter: clamp(24px, 4.5vw, 64px);
  --page: min(1200px, 100% - 2 * var(--gutter));
  --sans: "Hanken Grotesk", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", system-ui, sans-serif;
  --song: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, monospace;
  position: relative;
  margin-top: clamp(72px, 9vw, 140px);
  font-family: var(--sans);
  color: var(--ink);
}
.akhw *, .akhw *::before, .akhw *::after { box-sizing: border-box; }

.akhw-head { width: var(--page); margin: 0 auto; }
.akhw-num { display: block; margin-bottom: 20px; font-family: var(--song); font-size: 15px; color: var(--zhu); }
.akhw-num span { margin-left: 14px; font-family: var(--sans); font-size: 12.5px; letter-spacing: 0.04em; color: var(--faint); }
.akhw-head h2 {
  margin: 0;
  font-weight: 300;
  font-size: clamp(26px, 2.5vw, 34px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.akhw:lang(zh) .akhw-head h2 { font-family: var(--song); letter-spacing: 0.04em; word-break: keep-all; }
.akhw-lede { margin: 10px 0 0; font-size: 15px; color: var(--gray); }

/* Stage */

.akhw-stage {
  position: relative;
  width: 100%;
  height: clamp(420px, min(56.25vw, 100svh - 260px), 760px);
  margin: clamp(16px, 2.4vh, 28px) 0 0;
  overflow: hidden;
  isolation: isolate;
  background: #fff;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}
.akhw-canvas {
  -webkit-touch-callout: none;
  user-select: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: filter 0.9s ease, opacity 1.6s ease;
}
/* The room comes up out of the page's white. */
.akhw.is-ready .akhw-canvas, .akhw.is-still .akhw-canvas { opacity: 1; }
.akhw.is-gate .akhw-canvas { filter: blur(6px) saturate(0.85) brightness(1.04); }
.akhw.is-gate.is-later .akhw-canvas { filter: none; }
/* No hard edge between the page and the room: the top and bottom of the
   stage dissolve into white. */
.akhw-stage::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  /* The stage runs the full width of the window; only an object that
     crosses its top or bottom edge is softened here. */
  background:
    linear-gradient(to bottom, #fff, rgba(255, 255, 255, 0) 2.5%),
    linear-gradient(to top, #fff, rgba(255, 255, 255, 0) 2.5%);
  pointer-events: none;
}
.akhw-stage::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 0;
  top: 0;
  width: min(62%, 860px);
  height: 46%;
  background: radial-gradient(ellipse 100% 100% at 0 0, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.62) 45%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
}
.akhw.is-still .akhw-stage::after, .akhw.no-gl .akhw-stage::after { display: none; }
.akhw-poster { display: none; position: absolute; inset: 0; }
.akhw-poster img { width: 100%; height: 100%; object-fit: cover; }
.akhw.no-gl .akhw-poster { display: block; }
.akhw.no-gl .akhw-canvas, .akhw.no-gl .akhw-tags, .akhw.no-gl .akhw-say { display: none; }

.akhw-frame { position: relative; }

/* Captions: one at a time, top-left like a film title card. */
.akhw-say {
  position: absolute;
  z-index: 3;
  left: calc((100% - var(--page)) / 2);
  top: clamp(16px, 4%, 36px);
  width: min(26em, 40%);
  pointer-events: none;
}
.akhw-say p {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  font-size: clamp(19px, 1.6vw, 24px);
  font-weight: 300;
  line-height: 1.25;
  letter-spacing: -0.01em;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.akhw:lang(zh) .akhw-say p { font-family: var(--song); letter-spacing: 0.04em; line-height: 1.35; }
.akhw-say p { color: var(--ink); text-wrap: pretty; }
.akhw-say p span { display: block; margin-top: 0.5em; font-family: var(--sans); font-size: 15px; font-weight: 300; line-height: 1.65; letter-spacing: 0; color: var(--gray); }
.akhw-say p.on { opacity: 1; transform: none; transition: opacity 0.5s ease 0.24s, transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.24s; }

/* Labels pinned to things in the scene. */
.akhw-tags { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.akhw-tag {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font-size: 13.5px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s ease;
  will-change: transform, opacity;
}
.akhw-tag.on { opacity: 1; }
.akhw-tag b { display: block; font-weight: 500; color: var(--ink); font-size: 15px; }
.akhw-tag small { display: block; font-size: 13px; color: var(--gray); }
/* Names lie on the walnut itself, light like a film's lower third. */
.akhw-tag.is-id { text-shadow: 0 1px 2px rgba(20, 12, 6, 0.55), 0 0 14px rgba(20, 12, 6, 0.35); }
.akhw-tag.is-id b { color: #f6f2ec; }
.akhw-tag.is-id small { color: rgba(246, 242, 236, 0.8); }
/* Paper labels: solid, so nothing has to re-blur the scene behind them. */
.akhw-tag.is-pill {
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 6px 18px -8px rgba(40, 50, 70, 0.35);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.akhw-tag.is-pill.is-key { color: var(--zhu); }
.akhw-tag.is-pill.is-zero { font-size: 17px; padding: 8px 20px; }
.akhw-tag.is-pill.is-zero em { font-style: normal; font-variant-numeric: tabular-nums; color: var(--zhu); font-weight: 600; }

/* The approval prompt: Ask Key's real alert layout, 300 pt wide. */
.akhw-alert {
  --s: 1.14;
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  width: 300px;
  padding: 24px 16px 14px;
  border-radius: 14px;
  background: rgba(236, 236, 236, 0.9);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  backdrop-filter: blur(30px) saturate(1.6);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.22), 0 24px 60px -12px rgba(0, 0, 0, 0.35), 0 8px 18px -8px rgba(0, 0, 0, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.38;
  color: #1d1d1f;
  text-align: center;
  transform: translate(-50%, -50%) scale(var(--s));
  transform-origin: 50% 50%;
  user-select: text;
  -webkit-user-select: text;
}
.akhw-alert[hidden] { display: none; }
.akhw-alert.enter { animation: akhw-alert-in 0.42s cubic-bezier(0.2, 0.9, 0.25, 1.15) both; }
.akhw-alert.leave { animation: akhw-alert-out 0.28s ease-in both; }
@keyframes akhw-alert-in { from { opacity: 0; transform: translate(-50%, -46%) scale(calc(var(--s) * 0.92)); } to { opacity: 1; transform: translate(-50%, -50%) scale(var(--s)); } }
@keyframes akhw-alert-out { to { opacity: 0; transform: translate(-50%, -50%) scale(calc(var(--s) * 0.96)); } }
.akhw-alert-icon { display: block; width: 64px; height: 64px; margin: 0 auto 12px; }
.akhw-alert strong { display: block; font-weight: 700; }
.akhw-alert-run { margin-top: 8px; }
.akhw-alert code { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12px; }
.akhw-alert-details {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: #0a7aff;
  cursor: pointer;
}
.akhw-alert-details svg { width: 9px; height: 9px; transition: transform 0.2s ease; }
.akhw-alert-details[aria-expanded="true"] svg { transform: rotate(90deg); }
.akhw-alert-rows {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  text-align: left;
}
.akhw-alert-rows[hidden] { display: none; }
.akhw-alert-rows dt { color: #6e6e73; white-space: nowrap; }
.akhw-alert-rows dd { margin: 0; }
.akhw-alert-actions { display: grid; gap: 8px; margin-top: 16px; }
.akhw-btn {
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.18), 0 0.5px 1px rgba(0, 0, 0, 0.14);
  font: inherit;
  color: #1d1d1f;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.akhw-btn:hover { filter: brightness(0.97); }
.akhw-btn:active, .akhw-btn.pressed { filter: brightness(0.82); transform: scale(0.985); }
.akhw-btn.is-primary { background: #0a7aff; color: #fff; box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.2); }
.akhw-btn:focus-visible, .akhw-alert-details:focus-visible, .akhw-later:focus-visible { outline: 3px solid rgba(10, 122, 255, 0.5); outline-offset: 1px; }
.akhw-alert-foot { margin-top: 12px; font-size: 11px; color: #8a8a8e; }
.akhw-count { font-variant-numeric: tabular-nums; }
.akhw-later { padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.akhw-later:hover { color: #1d1d1f; }
.akhw.is-hinting .akhw-btn.is-primary { animation: akhw-nudge 2.4s ease-in-out infinite; }
@keyframes akhw-nudge { 0%, 70%, 100% { box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.2), 0 0 0 0 rgba(10, 122, 255, 0.45); } 85% { box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.2), 0 0 0 7px rgba(10, 122, 255, 0); } }

.akhw-hint {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: clamp(18px, 5%, 48px);
  margin: 0;
  transform: translateX(-50%);
  font-size: 13px;
  color: var(--gray);
  white-space: nowrap;
}
.akhw-hint[hidden] { display: none; }
.akhw-pending {
  position: absolute;
  z-index: 5;
  right: calc((100% - var(--page)) / 2);
  top: clamp(20px, 5%, 44px);
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(236, 236, 236, 0.92);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.12), 0 10px 26px -12px rgba(40, 50, 70, 0.45);
  font: inherit;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
}
.akhw-pending::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 9px; border-radius: 50%; background: var(--zhu); vertical-align: 1px; animation: akhw-blink 1.4s ease-in-out infinite; }
@keyframes akhw-blink { 50% { opacity: 0.25; } }
.akhw-pending[hidden] { display: none; }

.akhw-end {
  position: absolute;
  z-index: 4;
  left: calc((100% - var(--page)) / 2);
  bottom: clamp(18px, 5%, 40px);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.akhw-end[hidden] { display: none; }
.akhw-end button, .akhw-play {
  padding: 8px 18px;
  border: 1px solid var(--zhu);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--zhu);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.akhw-end button:hover, .akhw-play:hover { background: var(--zhu); color: #fff; }
.akhw-end .akhw-other { border-color: rgba(26, 26, 26, 0.22); color: var(--ink); }
.akhw-end .akhw-other:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.akhw-play { position: absolute; z-index: 4; left: 50%; bottom: clamp(18px, 5%, 48px); transform: translateX(-50%); }
.akhw-play[hidden] { display: none; }
.akhw button:focus-visible { outline: 1px solid var(--zhu); outline-offset: 4px; }

/* Chapter rail. Holds the full story as real text; in the animated telling
   the text is visually hidden and shown one line at a time as a caption. */
.akhw-steps {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0 clamp(10px, 1.6vw, 24px);
  width: var(--page);
  margin: 10px auto 0;
  padding: 0;
  list-style: none;
}
.akhw-steps button {
  position: relative;
  width: 100%;
  padding: 6px 0 12px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  font-weight: 400;
  text-align: left;
  color: var(--faint);
  cursor: pointer;
}
.akhw-steps button b { font-weight: 400; }
.akhw-steps button:hover, .akhw-steps li.on button { color: var(--ink); }
.akhw-steps button i { position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--line); }
.akhw-steps button i::after { content: ""; position: absolute; inset: 0; background: var(--zhu); transform-origin: 0 50%; transform: scaleX(var(--fill, 0)); }
.akhw-steps p {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.akhw-steps p span { color: var(--gray); }
.akhw-steps p[data-when] { display: none; }
.akhw[data-outcome="allow"] .akhw-steps p[data-when="allow"],
.akhw[data-outcome="timed"] .akhw-steps p[data-when="timed"],
.akhw[data-outcome="timed"] .akhw-steps li[data-step="5"] p[data-when="allow"],
.akhw[data-outcome="deny"] .akhw-steps p[data-when="deny"],
.akhw[data-outcome="expire"] .akhw-steps p[data-when="expire"] { display: block; }

.akhw-note {
  width: var(--page);
  max-width: 760px;
  margin: 28px auto 0;
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
  color: var(--faint);
}

/* Still telling: reduced motion, or no WebGL. The stage shows one composed
   frame and the rail becomes a readable list of all six steps. */
.akhw.is-still .akhw-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px clamp(20px, 3vw, 44px); margin-top: 32px; }
.akhw.is-still .akhw-steps button { color: var(--ink); cursor: default; pointer-events: none; }
.akhw.is-still .akhw-steps button i::after { transform: scaleX(1); }
.akhw.is-still .akhw-steps p {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.6;
}
.akhw.is-still .akhw-say, .akhw.is-still .akhw-play { display: none; }
.akhw.is-still .akhw-alert { animation: none; }

.akhw-still-alert { display: flex; justify-content: center; width: var(--page); margin: 32px auto 0; }
.akhw-still-alert .akhw-alert { position: static; transform: none; animation: none; box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.22), 0 12px 30px -12px rgba(0, 0, 0, 0.3); }

/* On wide, landscape screens the whole chapter, title to rail, fits one
   screen. Portrait tablets keep their natural height instead of padding
   the scene with empty space. */
@media (min-width: 701px) and (min-aspect-ratio: 1 / 1) {
  .akhw:not(.is-still) { min-height: min(100svh, 980px); display: flex; flex-direction: column; justify-content: center; }
}

/* Phones and portrait tablets: the scene is recomposed upright by the
   script; here the caption moves under the scene so it never covers it. */
@media (max-width: 700px), (max-aspect-ratio: 1 / 1) {
  .akhw-stage { width: 100%; height: clamp(520px, 78svh, 760px); }
  .akhw-stage::after { display: none; }
  .akhw-say {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    height: 7.2em;
    margin: 18px var(--gutter) 0;
  }
  .akhw-say p { font-size: 22px; right: 0; color: var(--ink); }
  .akhw-say p span { color: var(--gray); }
  .akhw-alert { --s: 1; width: 280px; padding: 20px 14px 12px; }
  .akhw-alert-icon { width: 52px; height: 52px; margin-bottom: 10px; }
  .akhw-steps { gap: 0 8px; }
  .akhw-steps button { font-size: 12.5px; }
  .akhw.is-still .akhw-steps { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .akhw-tag { font-size: 11.5px; }
  .akhw-tag b { font-size: 12.5px; }
  .akhw-tag.is-pill { font-size: 12px; padding: 4px 10px; }
  .akhw-tag.is-pill.is-zero { font-size: 13px; padding: 6px 13px; }
  .akhw-end { left: 50%; transform: translateX(-50%); flex-wrap: nowrap; }
  .akhw-end button { white-space: nowrap; font-size: 13.5px; padding: 8px 14px; }
  .akhw-bar, .akhw-foot { padding: 20px var(--gutter, 24px); }
  .akhw-foot { flex-direction: column; align-items: flex-start; gap: 8px; }
}
/* Portrait tablets: a square stage, so the upright composition has room. */
@media (min-width: 701px) and (max-aspect-ratio: 1 / 1) {
  .akhw-stage { height: min(100vw, 80svh); }
}
