/* Hiya.to site styles.
   One fixed WebGL stage on the home page; the page scrolls over it like a letter.
   Logical properties (inline/block) throughout so rtl languages mirror cleanly. */

:root {
  --paper: #F2F5F9;
  --text: #0E1F45;
  --muted: #56637E;
  --brand: #14306B;
  --dot: #14306B;
  --coral: #F2643D;
  --line: rgba(20, 48, 107, .16);
  --field: #FFFFFF;
  --shadow: rgba(20, 48, 107, .5);

  --f-display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-cjk-display: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --max: 1240px;
  --gutter-s: max(16px, env(safe-area-inset-left, 0px), calc((100vw - var(--max)) / 2));
  --gutter-e: max(16px, env(safe-area-inset-right, 0px), calc((100vw - var(--max)) / 2));
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0A1531; --text: #E9EFFB; --muted: #9AA8C6; --brand: #DCE6FA; --dot: #8DA6DD;
    --coral: #FF7450; --line: rgba(205, 220, 250, .18); --field: #101E40; --shadow: rgba(0, 0, 0, .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: hidden; overflow-x: clip; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--paper); color: var(--text);
  font: 16px/1.7 var(--f-body); -webkit-font-smoothing: antialiased; overflow-x: hidden; overflow-x: clip;
}
:lang(zh) h1, :lang(zh) h2 { font-family: var(--f-cjk-display); }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 16px; top: -60px; z-index: 10; background: var(--brand); color: var(--paper); padding: 8px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }
.inner { padding-inline: var(--gutter-s) var(--gutter-e); }
[dir="rtl"] .inner { padding-inline: var(--gutter-e) var(--gutter-s); }

/* logo and bow tie colours */
.logo { display: block; height: 30px; width: auto; }
.i { fill: var(--brand); } .k { fill: var(--coral); }

/* top bar */
.top { position: absolute; inset-inline: 0; top: 0; z-index: 3; padding-top: env(safe-area-inset-top, 0px); }
.top .inner { display: flex; align-items: center; gap: 28px; padding-block: 22px; }
.top nav { display: flex; gap: 26px; margin-inline-start: auto; font-size: 15px; }
.top nav a { text-decoration: none; opacity: .82; }
.top nav a:hover, .top nav a[aria-current="page"] { opacity: 1; text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }

/* language menu */
.langsel { position: relative; }
.langbtn { display: flex; align-items: center; gap: 7px; font: 500 14px var(--f-body); color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px 6px 11px; cursor: pointer; }
.langbtn:hover, .langbtn[aria-expanded="true"] { border-color: var(--brand); }
.langbtn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.langbtn .chev { width: 11px; height: 11px; transition: transform .2s; }
.langbtn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.langmenu { position: absolute; inset-inline-end: 0; top: calc(100% + 10px); width: min(460px, calc(100vw - 32px)); max-height: min(70vh, 520px); overflow: auto; background: var(--field); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px -24px var(--shadow); padding: 10px; z-index: 5; }
.lm-head { margin: 0; padding: 6px 10px 10px; font-size: 12.5px; color: var(--muted); letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.langmenu ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.langmenu a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 9px; text-decoration: none; font-size: 14.5px; }
.langmenu a small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.langmenu a:hover, .langmenu a:focus-visible { background: var(--paper); outline: none; }
.langmenu a[aria-current="true"] { background: var(--paper); color: var(--brand); font-weight: 600; }
.langmenu a[aria-current="true"]::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); align-self: center; flex: none; }
.langmenu a[aria-current="true"] small { display: none; }

/* handle field */
.claim { display: flex; align-items: center; background: var(--field); border: 1px solid var(--line); border-radius: 999px; padding-block: 5px; padding-inline: 20px 5px; max-width: 27rem; box-shadow: 0 10px 30px -18px var(--shadow); }
.claim:focus-within { border-color: var(--brand); }
.claim label { font-weight: 500; color: var(--muted); white-space: nowrap; direction: ltr; }
.claim input { flex: 1; min-width: 0; border: 0; background: transparent; font: 500 16px var(--f-body); color: var(--text); padding: clamp(6px, 1.1svh, 10px) 4px; outline: none; direction: ltr; }
.claim input:focus-visible { outline: none; }
.claim button { border: 0; border-radius: 999px; background: var(--brand); color: var(--paper); font: 600 15px var(--f-body); padding: 11px 22px; cursor: pointer; white-space: nowrap; }
.claim button:hover { filter: brightness(1.15); }
.hint { margin: 0; font-size: 13.5px; color: var(--muted); min-height: 1.6em; line-height: 1.6; }
.hint.bad { color: var(--coral); }

/* ---------- home ---------- */
/* opening: Hiya.to typed on a full-screen field, then fades into the page */
.intro { display: none; position: fixed; inset: 0; z-index: 30; background: #14306B; place-items: center; padding-inline: 16px; }
.intro-on .intro { display: grid; animation: intro-fallback .6s ease 4.2s forwards; }
.intro-out .intro { opacity: 0; transition: opacity .7s ease; }
.intro-on body { overflow: hidden; }
#introMark { width: min(64vw, 440px); height: auto; overflow: visible; }
#introMark .iw { fill: #FFFFFF; }
#introMark .k { fill: #F2643D; }
#introMark .ch { opacity: 0; }
#introMark .ch.on { opacity: 1; }
#introCaret { fill: #F2643D; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
@keyframes intro-fallback { to { opacity: 0; visibility: hidden; } }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; pointer-events: none; }
.stage-fallback { display: none; position: fixed; left: 50%; top: 50%; width: min(80vw, 620px); transform: translate(-50%, -50%); z-index: 0; }
.no-gl .stage-fallback { display: block; }
.page-home main, .page-home .foot { position: relative; z-index: 1; }

.hero {
  height: 100vh; height: 100svh; min-height: 460px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr) auto;
  padding-block: clamp(62px, 9.5svh, 84px) clamp(16px, 3.2svh, 30px);
  padding-inline: var(--gutter-s) var(--gutter-e);
}
.hero h1 { margin: 0; font-weight: 500; max-width: 15em; }
:lang(zh) .hero h1 { max-width: 14em; }
.l1, .l2 { font-family: var(--f-display); font-size: clamp(36px, min(5.8vw, 10svh), 92px); line-height: 1; letter-spacing: -.02em; color: var(--brand); text-wrap: balance; margin: 0; }
:lang(zh) .l1, :lang(zh) .l2 { font-family: var(--f-cjk-display); font-weight: 700; font-style: normal; letter-spacing: .02em; line-height: 1.15; font-size: clamp(32px, min(5.4vw, 9svh), 84px); }
.l2 { max-width: 12em; }
.l1 { grid-column: 1 / -1; grid-row: 1; font-weight: 500; padding-top: 1svh; }
.l2 { grid-column: 2; grid-row: 3; font-style: italic; align-self: end; text-align: end; padding-bottom: 6px; }
.dot { color: var(--coral); }
.hero-foot { grid-column: 1; grid-row: 3; align-self: end; max-width: 32rem; display: flex; flex-direction: column; gap: clamp(6px, 1.2svh, 12px); min-width: 0; }
/* "Hiya" drawn with the logo's own letters inside a headline */
.brand-word { display: inline-block; height: 1.02em; width: auto; vertical-align: -0.29em; margin-inline: .06em; }
:lang(zh) .brand-word { height: 1.1em; vertical-align: -0.3em; margin-inline: .14em; }
.sub { margin: 0; font-size: clamp(16px, 2.4svh, 21px); line-height: 1.5; color: var(--text); text-wrap: balance; }
.lede { margin: 0; color: var(--text); opacity: .86; font-size: clamp(14.5px, 2.1svh, 17.5px); line-height: 1.6; }

.beat { position: relative; height: 190svh; }
.note { position: sticky; top: 56svh; max-width: 27rem; display: flex; flex-direction: column; gap: 12px; padding-block: 6px; isolation: isolate; }
.note::before { content: ""; position: absolute; inset: -60px max(-90px, calc(-1 * var(--gutter-s))); z-index: -1; background: radial-gradient(closest-side, var(--paper) 55%, transparent); opacity: .92; }
.note.end-side { margin-inline-start: auto; }
.mark { font: 500 13px/1.3 var(--f-body); letter-spacing: .14em; text-transform: uppercase; color: var(--coral); }
:lang(zh) .mark { letter-spacing: .08em; }
.note h2 { font-weight: 700; font-size: clamp(28px, 3.4vw, 44px); line-height: 1.2; margin: 0; text-wrap: balance; }
.note p { margin: 0; color: var(--muted); }
.letter { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.letter div { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 10px; }
:lang(zh) .letter div { grid-template-columns: 5.2em minmax(0, 1fr); }
.letter b { font-weight: 600; font-size: 13px; padding-top: 2px; }
.letter .fw span { color: var(--coral); }
.note .more { align-self: flex-start; font-weight: 600; color: var(--brand); text-decoration: none; border-bottom: 1px solid var(--coral); padding-bottom: 2px; }
.note .more::after { content: " →"; }
[dir="rtl"] .note .more::after { content: " ←"; }

.tags { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; font: 500 12.5px/1 var(--f-body); color: var(--muted); white-space: nowrap; opacity: 0; will-change: transform, opacity; }
.tag.ai { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); }
.tag.who { font-size: 14px; color: var(--text); text-align: center; }
:lang(zh) .tag.who { font-family: var(--f-cjk-display); }
.tag.who small { display: block; font: 12px var(--f-body); color: var(--muted); margin-top: 4px; }

.closing { min-height: 100svh; display: flex; flex-direction: column; justify-content: flex-end; padding-bottom: 40px; }
.closing .inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px 40px; align-items: end; }
.closing h2 { font-weight: 700; font-size: clamp(30px, 4vw, 52px); margin: 0; line-height: 1.2; text-wrap: balance; }
.closing .col { display: flex; flex-direction: column; gap: 14px; min-width: 0; max-width: 30rem; }
.closing-mark { grid-column: 2; grid-row: 1; padding: 0; }

/* footer */
.foot .inner { border-top: 1px solid var(--line); padding-block: 20px 28px; display: flex; flex-wrap: wrap; gap: 10px 26px; font-size: 14px; color: var(--muted); }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--text); }
.foot { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* back to top */
.totop { position: fixed; z-index: 4; inset-inline-end: calc(max(16px, env(safe-area-inset-right, 0px)) + 8px); bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--field); color: var(--brand); display: grid; place-items: center; cursor: pointer; box-shadow: 0 12px 30px -14px var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .35s, transform .35s, border-color .2s; }
.totop.on { opacity: 1; transform: none; pointer-events: auto; }
.totop:hover { border-color: var(--brand); }
.totop svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { .totop, .langbtn .chev { transition: none; } }

/* ---------- features ---------- */
.paper { padding-block: 120px 40px; }
.paper > * { padding-inline: var(--gutter-s) var(--gutter-e); }
.f-head { display: grid; gap: 20px; max-width: calc(var(--max) + 32px); padding-bottom: 56px; }
.f-mark { width: 88px; height: auto; }
.f-head h1 { font-family: var(--f-display); font-weight: 500; font-size: clamp(42px, 7vw, 96px); line-height: 1; letter-spacing: -.02em; margin: 0; color: var(--brand); text-wrap: balance; }
:lang(zh) .f-head h1 { font-family: var(--f-cjk-display); font-weight: 700; letter-spacing: .02em; line-height: 1.15; }
.f-head .lede { font-size: 18px; max-width: 38rem; }
.f-section, .f-cta { position: relative; }
.f-section::before, .f-cta::before { content: ""; position: absolute; top: 0; inset-inline: var(--gutter-s) var(--gutter-e); border-top: 1px solid var(--line); }
.f-section { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 16px 48px; padding-block: 40px; }
.f-label, :lang(zh) .f-label { margin: 0; font: 500 13px/1.6 var(--f-body); letter-spacing: .14em; text-transform: uppercase; color: var(--coral); }
:lang(zh) .f-label { letter-spacing: .08em; font-size: 14px; }
.f-section h3 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.f-section p { margin: 0; color: var(--muted); }
.ways, .kinds { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 28px 40px; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 28px 40px; }
.steps li { counter-increment: step; }
.steps li::before { content: counter(step); display: block; font: italic 400 44px/1 var(--f-display); color: var(--brand); margin-bottom: 10px; }
.private { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 18px; }
.private li { display: flex; gap: 12px; align-items: baseline; }
.private li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); flex: none; transform: translateY(-2px); }
.f-cta { display: grid; gap: 14px; padding-block: 64px 40px; }
.f-cta h2 { margin: 0; font-size: clamp(28px, 3.6vw, 44px); line-height: 1.2; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .top .inner { gap: 14px; }
  .top nav { gap: 14px; font-size: 14px; }
  .logo { height: 22px; }
  .langbtn { padding: 5px 9px; }
  .langbtn .globe { display: none; }
  .langmenu ul { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; padding-block: clamp(58px, 9svh, 72px) clamp(14px, 2.6svh, 24px); }
  .l1, .l2 { font-size: clamp(30px, min(9.5vw, 6.5svh), 56px); }
  :lang(zh) .l1, :lang(zh) .l2 { font-size: clamp(28px, min(8.6vw, 6svh), 52px); }
  .l2 { grid-column: 1; grid-row: 3; padding-bottom: clamp(8px, 2svh, 18px); }
  .hero-foot { grid-row: 4; }
  .note, .note.end-side { margin-inline-start: 0; top: 50svh; }
  .closing .inner { grid-template-columns: minmax(0, 1fr); }
  .closing-mark { grid-column: 1; grid-row: auto; }
  .f-section { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) { .top nav a:nth-child(2) { display: none; } }
