/* Nihongo Desk — editorial stylesheet
   Concept "sumi & shu": ink-tinted slate neutrals (sumi, the ink of a brush) carry the text,
   one vermilion accent (shu, the red of a name seal) marks the brand, links and Japanese words.
   No cream paper, no neon, no gradients. One file, no images, no JS. */

:root {
  /* ---- Type ------------------------------------------------------------------------------
     Body:     Literata — a book face designed for long screen reading; calm, sturdy serifs.
     Headings: Schibsted Grotesk — a news-publisher grotesque; firm, plain, a little warm.
     Japanese: Noto Serif JP inside running text (matches the serif body), Noto Sans JP next to
               the grotesque. Local Hiragino / Yu fonts follow as fallbacks. */
  --font-body: "Literata", "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;
  --font-head: "Schibsted Grotesk", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --font-ja: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --text-body: clamp(1.0625rem, 0.98rem + 0.35vw, 1.1875rem); /* 17px phone -> 19px desktop */
  --text-small: 0.9375rem;
  --text-tiny: 0.8125rem;
  --leading: 1.72;

  /* ---- Layout ----------------------------------------------------------------------------
     One centred column. Prose is held to ~34em (about 65-70 characters a line in Literata);
     the frame around it is a little wider so headlines and the masthead can breathe. */
  --measure: 33em;
  --page: 46rem;
  --gutter: clamp(1rem, 4.5vw, 2rem);   /* never below 16px at the sides */
  --radius: 4px;

  /* ---- Colour: light ---------------------------------------------------------------------
     Neutrals lean slightly blue (ink on cool paper); the accent is a deep vermilion that
     passes AA on the paper (about 5.7:1). */
  --bg: #f7f8fa;          /* paper */
  --surface: #edf0f4;     /* bands, table heads, code */
  --rule: #d4dae3;        /* hairlines */
  --text: #1a2130;        /* sumi ink */
  --text-2: #465063;      /* secondary text */
  --text-3: #636d80;      /* meta, captions */
  --accent: #b8321f;      /* shu vermilion */
  --accent-ink: #ffffff;  /* text on the accent */
  --ja-mark: #f3d9d3;     /* marker under Japanese words */
  --selection: #f3d9d3;
}

/* ---- Colour: dark --------------------------------------------------------------------------
   Deep slate rather than black; the accent lifts to a soft vermilion, not a glow. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161d;
    --surface: #1a1f28;
    --rule: #2b3341;
    --text: #e3e7ed;
    --text-2: #b4bcc9;
    --text-3: #8d96a5;
    --accent: #ef7a62;
    --accent-ink: #12161d;
    --ja-mark: #4a2a25;
    --selection: #4a2a25;
  }
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--leading);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--selection); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.wrap { max-width: var(--page); margin-inline: auto; padding-inline: var(--gutter); }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: var(--gutter); top: 0.5rem; background: var(--bg); padding: 0.4rem 0.7rem; z-index: 10; }

/* Japanese words: a separate typeface everywhere, plus a quiet marker underlay inside reading text. */
[lang="ja"] { font-family: var(--font-ja); font-weight: 500; }
.prose [lang="ja"], .card-summary [lang="ja"] {
  font-size: 1.04em;
  padding-inline: 0.06em;
  background: linear-gradient(transparent 64%, var(--ja-mark) 64%);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
[lang="ja"] [lang="ja"] { font-size: 1em; padding: 0; background: none; }
h1 [lang="ja"], h2 [lang="ja"], h3 [lang="ja"] { font-family: "Noto Sans JP", var(--font-head); }

/* Name seal: the one decorative element of the brand. */
.seal {
  display: inline-grid; place-items: center;
  width: 1.85rem; height: 1.85rem; flex: none;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 3px;
  font-family: var(--font-ja); font-weight: 500; font-size: 1.05rem; line-height: 1;
}

/* ---- Header ---- */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.6rem 1.5rem; padding-block: 1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.65rem;
  color: var(--text); text-decoration: none;
  font: 700 1.2rem/1.2 var(--font-head); letter-spacing: -0.01em;
}
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.site-nav a {
  display: inline-block; padding-block: 0.2rem;
  color: var(--text-2); text-decoration: none;
  font: 500 var(--text-small)/1.4 var(--font-head);
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--text); border-bottom-color: var(--rule); }
.site-nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---- Shared small type ---- */
.kicker, .section-label {
  margin: 0;
  font: 700 var(--text-tiny)/1.4 var(--font-head);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-3);
}
.kicker [lang="ja"] { letter-spacing: 0.2em; color: var(--accent); }

/* ---- Home ---- */
.masthead { padding-block: clamp(2.5rem, 8vw, 5rem) clamp(2rem, 5vw, 3.25rem); }
.masthead h1 {
  margin: 0.5rem 0 1rem;
  font: 700 clamp(2.6rem, 1.5rem + 5vw, 4.4rem)/1 var(--font-head);
  letter-spacing: -0.035em;
}
.lede { margin: 0; max-width: 28em; font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem); line-height: 1.5; color: var(--text-2); }
.section-label { padding-bottom: 0.8rem; }
.cards { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--text); }
.card { position: relative; padding-block: 1.6rem; border-bottom: 1px solid var(--rule); }
.card time { font: 500 var(--text-tiny)/1.4 var(--font-head); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.card h3 {
  margin: 0.35rem 0 0.55rem;
  font: 700 clamp(1.25rem, 1.05rem + 0.8vw, 1.55rem)/1.25 var(--font-head);
  letter-spacing: -0.012em;
}
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; }
.card:hover h3 a { color: var(--accent); }
.card-summary { margin: 0; max-width: var(--measure); color: var(--text-2); }
.empty { color: var(--text-2); }

/* ---- Article and page headers ---- */
.post-header { padding-block: clamp(2.25rem, 6vw, 4rem) 1.75rem; }
.post-header h1 {
  margin: 0.55rem 0 1rem;
  font: 700 clamp(1.95rem, 1.3rem + 2.8vw, 2.85rem)/1.12 var(--font-head);
  letter-spacing: -0.022em;
  text-wrap: pretty;
}
.post-meta {
  display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; margin: 0;
  font: 500 var(--text-small)/1.5 var(--font-head); color: var(--text-3);
}
.reviewed { color: var(--text-2); }
.reviewed::before { content: "\2713"; color: var(--accent); font-weight: 700; margin-right: 0.35em; }

/* ---- Prose ---- */
.prose { max-width: var(--measure); overflow-wrap: break-word; hyphens: manual; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.15em; }
.prose h2 {
  margin: 2.4em 0 0.75em; padding-top: 0.9rem;
  border-top: 1px solid var(--rule);
  font: 700 clamp(1.35rem, 1.15rem + 0.7vw, 1.6rem)/1.25 var(--font-head);
  letter-spacing: -0.012em;
}
.prose h3 { margin: 1.9em 0 0.5em; font: 700 1.15em/1.3 var(--font-head); }
.prose h4 { margin: 1.6em 0 0.4em; font: 700 1em/1.35 var(--font-head); color: var(--text-2); }
.prose h2 + h3 { margin-top: 1em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: 0.45em; padding-left: 0.15em; }
.prose li::marker { color: var(--accent); }
.prose ol > li::marker { font-family: var(--font-head); font-weight: 700; font-size: 0.9em; }
.prose strong { font-weight: 650; }
.prose a { color: var(--text); text-decoration-color: var(--accent); overflow-wrap: anywhere; }
.prose a:hover { color: var(--accent); }
.prose blockquote {
  margin: 1.7em 0; padding: 0.1em 0 0.1em 1.25em;
  border-left: 3px solid var(--accent);
  color: var(--text-2); font-style: italic;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5em 0; }
.prose code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 3px;
  padding: 0.08em 0.35em;
}
.prose pre {
  margin: 1.6em 0; padding: 1rem 1.1rem; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  line-height: 1.55;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: 0.85em; }
.table-wrap {
  margin: 1.7em 0; overflow-x: auto;
  border: 1px solid var(--rule); border-radius: var(--radius);
}
.prose table {
  width: 100%; min-width: 32rem; border-collapse: collapse;
  font: var(--text-small)/1.5 var(--font-head);
}
.prose th, .prose td { padding: 0.65rem 0.85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.prose th { background: var(--surface); font-weight: 700; color: var(--text); }
.prose tr:last-child td { border-bottom: 0; }
.prose td + td, .prose th + th { border-left: 1px solid var(--rule); }

/* The disclosure band at the top of every article. */
.disclosure {
  margin: 0 0 2.2em; padding: 0.85rem 1.1rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  font: var(--text-small)/1.55 var(--font-head); color: var(--text-2);
}
.aff { font: 500 var(--text-tiny)/1 var(--font-head); color: var(--text-3); white-space: nowrap; }

/* About the editor, at the end of an article. */
.editor-box {
  max-width: var(--measure); margin-top: 3.5rem; padding: 1.3rem 1.4rem;
  display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem;
  border: 1px solid var(--rule); border-top: 3px solid var(--text); border-radius: 0 0 var(--radius) var(--radius);
  font-family: var(--font-head); color: var(--text-2);
}
.editor-box p { font-size: var(--text-small); line-height: 1.6; }
.editor-box .seal { grid-row: span 2; margin-top: 0.15rem; }
.editor-box h2 { margin: 0; font: 700 var(--text-tiny)/1.5 var(--font-head); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.editor-box p { margin: 0; }
.editor-box strong { color: var(--text); }

/* ---- Footer ---- */
.site-footer {
  margin-top: clamp(3.5rem, 9vw, 6rem);
  border-top: 1px solid var(--rule); background: var(--surface);
  font: var(--text-small)/1.6 var(--font-head); color: var(--text-2);
}
.site-footer .wrap { display: grid; gap: 0.9rem; padding-block: 2.25rem 2.75rem; }
.site-footer p { margin: 0; }
.footer-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; color: var(--text); }
.footer-brand .seal { width: 1.5rem; height: 1.5rem; font-size: 0.85rem; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; }
.footer-nav a, .site-footer a { color: var(--text-2); }
.footer-nav a:hover, .site-footer a:hover { color: var(--accent); }
.copyright { color: var(--text-3); font-size: var(--text-tiny); }

/* ---- Small screens ---- */
@media (max-width: 30rem) {
  .site-header .wrap { padding-block: 0.85rem; }
  .card { padding-block: 1.3rem; }
  .editor-box { grid-template-columns: 1fr; }
  .editor-box .seal { display: none; }
}

/* ---- Print: black on white, no navigation, link targets spelled out ---- */
@media print {
  :root {
    --bg: #fff; --surface: #fff; --rule: #999; --text: #000; --text-2: #222; --text-3: #444;
    --accent: #000; --accent-ink: #fff; --ja-mark: transparent;
  }
  body { font-size: 11pt; line-height: 1.5; }
  .site-nav, .footer-nav, .skip { display: none; }
  .wrap { max-width: none; padding: 0; }
  .site-footer { background: none; margin-top: 2rem; }
  .post-header { padding-block: 0 1rem; }
  .prose { max-width: none; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #444; }
  .prose h2, .prose h3 { break-after: avoid; }
  .prose table, .prose pre, .prose blockquote, .editor-box, .disclosure { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .prose table { min-width: 0; }
}
