/* Hanbi — Paper & Ink. One accent: vermilion. */
:root {
  --paper: #F4EFE6;
  --sheet: #FFFCF6;
  --ink: #1E1A16;
  --ink2: #6A6157;
  --verm: #C23B22;
  --line: rgba(30, 26, 22, .10);
  --ghost: rgba(30, 26, 22, .10);
  --grid-line: rgba(194, 59, 34, .38);
  --grid-guide: rgba(194, 59, 34, .20);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17140F;
    --sheet: #221E19;
    --ink: #F2ECE2;
    --ink2: #B3A99B;
    --verm: #E8694F;
    --line: rgba(255, 255, 255, .10);
    --ghost: rgba(242, 236, 226, .14);
    --grid-line: rgba(232, 105, 79, .45);
    --grid-guide: rgba(232, 105, 79, .22);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.6 -apple-system, "SF Pro Text", "SF Pro", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
:lang(vi) body, body:lang(vi) { line-height: 1.7; }
a { color: var(--verm); text-underline-offset: .18em; }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--verm); outline-offset: 3px; border-radius: 4px; }
.wrap { width: min(1080px, calc(100% - 48px)); margin: 0 auto; }

h1, h2 { font-family: -apple-system, "SF Pro Display", "SF Pro", "Segoe UI", system-ui, sans-serif; }
h1 { margin: 0; font-size: clamp(2.5rem, 6.2vw, 4rem); line-height: 1.06; font-weight: 750; letter-spacing: -.03em; max-width: 15ch; }
:lang(vi) h1 { line-height: 1.14; letter-spacing: -.02em; max-width: 15ch; }
:lang(th) h1 { line-height: 1.3; letter-spacing: 0; max-width: 12em; }
:lang(ko) h1, :lang(ja) h1 { line-height: 1.2; letter-spacing: -.01em; max-width: 9em; word-break: keep-all; }
:lang(ja) h1 { word-break: auto-phrase; }
:lang(th) body, body:lang(th) { line-height: 1.75; }
:lang(ko) body, body:lang(ko) { word-break: keep-all; }
:lang(ja) .sub, :lang(ja) .highlights p, :lang(ja) .doc p { line-break: strict; }

/* ---------- App identity ---------- */
.app-id { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; color: var(--ink); text-decoration: none; }
.app-id .appicon, .app-id .appicon img { display: block; width: 44px; height: 44px; border-radius: 22.37%; }
.app-id .appicon img { box-shadow: 0 0 0 1px rgba(30,26,22,.08); }
@media (prefers-color-scheme: dark) { .app-id .appicon img { box-shadow: 0 0 0 1px rgba(242,236,226,.12); } }
.app-id b { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; }
.app-id span[lang] { color: var(--ink2); font-size: 1rem; }

/* ---------- Hero ---------- */
.hero { padding: 72px 0 0; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 56px; align-items: center; }
.sub { margin: 22px 0 0; color: var(--ink2); font-size: 1.15rem; max-width: 34em; }

/* The signature: 汉笔 being written in two practice grids */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 0; }
.grid { width: 100%; height: auto; display: block; }
.g-fill { fill: var(--sheet); }
.g-border { fill: none; stroke: var(--grid-line); stroke-width: 9; }
.g-guide { stroke: var(--grid-guide); stroke-width: 7; stroke-dasharray: 36 36; fill: none; }
.g-diag { stroke: var(--grid-guide); stroke-width: 6; stroke-dasharray: 18 42; fill: none; }
.s-ink { fill: var(--ink); }
.s-ghost { fill: var(--ghost); }
.s-next { fill: var(--verm); fill-opacity: .28; }
.m-dot { fill: var(--verm); }
.m-halo { fill: var(--verm); fill-opacity: .16; transform-box: fill-box; transform-origin: center; animation: pulse 2.4s ease-in-out infinite; }
.m-arrow { stroke: var(--verm); stroke-opacity: .7; stroke-width: 14; stroke-linecap: round; fill: none; }
@keyframes pulse { 0%, 60%, 100% { transform: scale(1); } 30% { transform: scale(1.15); } }
.caption { margin: 14px 0 0; color: var(--ink2); font-size: .9rem; text-align: center; }

/* ---------- Highlights ---------- */
.highlights { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 80px 0 0; }
.highlights div { background: var(--sheet); border: 1px solid var(--line); border-radius: 24px; padding: 26px 26px 28px; }
.highlights div:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
.highlights h2 { margin: 0 0 8px; font-size: 1.22rem; line-height: 1.3; font-weight: 680; letter-spacing: -.01em; }
.highlights p { margin: 0; color: var(--ink2); }

/* ---------- Download ---------- */
.download { margin: 64px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
.download strong { font-size: 1.25rem; font-weight: 680; }
.download span { color: var(--ink2); }
.download .badge { display: inline-block; padding: 13px 13px 13px 0; line-height: 0; }
.download .badge img { display: block; height: 50px; width: auto; }

/* ---------- Docs pages ---------- */
.doc { padding: 56px 0 0; max-width: 46em; }
.doc h1 { font-size: clamp(2.2rem, 5vw, 3.1rem); max-width: none; }
.doc .lede { margin: 16px 0 0; color: var(--ink2); font-size: 1.12rem; }
.doc section { margin-top: 44px; }
.doc h2 { margin: 0 0 10px; font-size: 1.3rem; font-weight: 680; letter-spacing: -.01em; }
.doc p, .doc li { color: var(--ink); }
.doc ul { padding-left: 1.2em; }
.doc li + li { margin-top: 6px; }

.nw { white-space: nowrap; }
.muted { color: var(--ink2) !important; }
.contact { margin-top: 32px; background: var(--sheet); border: 1px solid var(--line); border-radius: 24px; padding: 26px; }
.contact p { margin: 0; }
.contact .mail { display: inline-block; margin: 6px 0 4px; font-size: 1.3rem; font-weight: 650; }
details { border-top: 1px solid var(--line); padding: 16px 0; }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 620; list-style: none; position: relative; padding-right: 28px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; position: absolute; right: 4px; top: -1px; color: var(--verm); font-weight: 500; font-size: 1.2rem; }
details[open] summary::after { content: "–"; }
details p { margin: 10px 0 0; color: var(--ink2); }
.files { list-style: none; padding: 0 !important; }
.files li { background: var(--sheet); border: 1px solid var(--line); border-radius: 18px; padding: 16px 20px; }
.files a { font-weight: 650; }

/* ---------- Footer ---------- */
footer { margin-top: 96px; border-top: 1px solid var(--line); padding: 28px 0 40px; font-size: .95rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; }
footer span { color: var(--ink2); }
footer a { color: var(--ink2); text-decoration: none; }
footer a:hover { color: var(--ink); text-decoration: underline; }
footer .langs { margin-left: auto; }
footer .langs ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
footer .langs a[aria-current] { color: var(--ink); font-weight: 600; }

@media (max-width: 860px) {
  .hero { padding-top: 44px; }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .pair { max-width: 460px; }
  .highlights { grid-template-columns: 1fr; margin-top: 56px; }
  footer .langs { margin-left: 0; flex-basis: 100%; }
}
@media (max-width: 400px) {
  .wrap { width: calc(100% - 32px); }
  .highlights div, .contact { padding: 22px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .m-halo { animation: none; }
}
