/* ---------------------------------------------------------------------------
   JPML — colours taken from the project icons (jpml-lang/assets).
   The traditional Japanese names are kept so the palette stays traceable:

     kon       #0F2540   the icon ground
     momo      #F596AA   the [SECTION] header
     sakura    #FEDFE1   nested values
     kurenai   #CB1B45   values in the light icon
     torinoko  #DAC9A6   keys
     byakugun  #83CCD2   numbers
     fuji      #A99CD6   keywords
--------------------------------------------------------------------------- */

@font-face {
    font-family: "IBM Plex Sans";
    src: url("/assets/fonts/IBMPlexSans-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans";
    src: url("/assets/fonts/IBMPlexSans-Medium.ttf") format("truetype");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans";
    src: url("/assets/fonts/IBMPlexSans-SemiBold.ttf") format("truetype");
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Sans";
    src: url("/assets/fonts/IBMPlexSans-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

/* ---------------------------------------------------------------------------
   Two themes, one palette.

   Dark is icon.svg: a kon ground, a momo header, torinoko keys, sakura values.
   Light is icon-light.svg read the same way: paper ground, a sakura panel, kon
   ink, kurenai values.

   Dark is the base. Light is applied either because the reader's system asks
   for it, or because the toggle wrote data-theme="light" on the root element,
   and the explicit choice wins in both directions:

     :root                                       dark
     @media light + :root:not([data-theme=dark]) light, by system preference
     :root[data-theme="light"]                   light, by the toggle
--------------------------------------------------------------------------- */

:root {
    /* 紺 kon. #192236 is the page, #0F2540 the icon's own ground. */
    --bg: #192236;
    --raised: rgb(255 255 255 / 4%);
    --line: rgb(154 182 214 / 16%);
    --line-strong: rgb(154 182 214 / 28%);
    --text: #e7eef7;
    --muted: #9db0c6;
    --faint: #8092aa;

    /* 桃 momo */
    --accent: #f596aa;
    --accent-strong: #f7aabb;
    --accent-dim: rgb(245 150 170 / 14%);
    --on-accent: #0f2540;

    --code-bg: #0f2540;
    --code-head: rgb(255 255 255 / 3%);
    --code-line: rgb(154 182 214 / 16%);

    /* Syntax, mirroring the scopes in the VS Code grammar. */
    --s-section: #f596aa;
    --s-key: #dac9a6;
    --s-string: #fedfe1;
    --s-number: #83ccd2;
    --s-keyword: #a99cd6;
    --s-comment: #8496ad;
    --s-punct: #8fa3bc;
    --s-error: #ff8f9e;
    --s-dim: #8496ad;

    color-scheme: dark;
    font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #fbfaf5;
        --raised: rgb(15 37 64 / 3%);
        --line: rgb(15 37 64 / 12%);
        --line-strong: rgb(15 37 64 / 24%);
        --text: #0f2540;
        --muted: #4a5f7a;
        --faint: #617288;

        --accent: #cb1b45;
        --accent-strong: #a81438;
        --accent-dim: rgb(203 27 69 / 9%);
        --on-accent: #fbfaf5;

        --code-bg: #fedfe1;
        --code-head: rgb(15 37 64 / 4%);
        --code-line: rgb(15 37 64 / 14%);

        --s-section: #0f2540;
        --s-key: #716246;
        --s-string: #c3183f;
        --s-number: #165e83;
        --s-keyword: #6f3381;
        --s-comment: #595857;
        --s-punct: #4a5a6e;
        --s-error: #c9171e;
        --s-dim: #5f646e;

        color-scheme: light;
    }
}

/* The same light values, chosen rather than inherited from the system. */

:root[data-theme="light"] {
    --bg: #fbfaf5;
    --raised: rgb(15 37 64 / 3%);
    --line: rgb(15 37 64 / 12%);
    --line-strong: rgb(15 37 64 / 24%);
    --text: #0f2540;
    --muted: #4a5f7a;
    --faint: #617288;

    --accent: #cb1b45;
    --accent-strong: #a81438;
    --accent-dim: rgb(203 27 69 / 9%);
    --on-accent: #fbfaf5;

    --code-bg: #fedfe1;
    --code-head: rgb(15 37 64 / 4%);
    --code-line: rgb(15 37 64 / 14%);

    --s-section: #0f2540;
    --s-key: #716246;
    --s-string: #c3183f;
    --s-number: #165e83;
    --s-keyword: #6f3381;
    --s-comment: #595857;
    --s-punct: #4a5a6e;
    --s-error: #c9171e;
    --s-dim: #5f646e;

    color-scheme: light;
}

* {
    box-sizing: border-box;
}

/* Several controls ship with the hidden attribute and are revealed by script.
   Class selectors that set `display` would otherwise beat the browser's own
   [hidden] rule and show a control that cannot work. */

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
}

.wrap {
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    padding-inline: 1.5rem;
}

.skip {
    position: absolute;
    top: -4rem;
    left: 1rem;
    z-index: 10;
    padding: 0.6rem 1rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.4rem;
    background: var(--bg);
    color: var(--text);
}

.skip:focus {
    top: 1rem;
}

a {
    color: inherit;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

a:hover {
    text-decoration-thickness: 2px;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 0.3rem;
}

code,
kbd,
pre {
    font-family: "IBM Plex Mono", ui-monospace, "Cascadia Code", "SFMono-Regular", monospace;
}

code {
    font-size: 0.86em;
}

h1,
h2,
h3,
h4 {
    line-height: 1.25;
    text-wrap: balance;
}

/* Top bar ---------------------------------------------------------------- */

.topbar {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
}

.brand {
    display: inline-flex;
    gap: 0.6rem;
    align-items: center;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
}

.brand img {
    border-radius: 0.5rem;
}

.brand .ext {
    color: var(--muted);
    font-weight: 400;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-size: 0.9rem;
}

.topbar nav a {
    color: var(--muted);
    text-decoration: none;
}

.topbar nav a:hover {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 0.3em;
}

/* Theme toggle. Hidden until main.js can make it work. */

.theme-toggle {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--line-strong);
    border-radius: 2rem;
    background: var(--raised);
    color: var(--muted);
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
    color: var(--text);
}

.theme-toggle svg {
    width: 0.95rem;
    height: 0.95rem;
    fill: none;
    stroke: currentcolor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* One icon and one label at a time: the theme the click would give you.
   Dark is the base, so the button offers light until something says otherwise. */

.theme-toggle .to-light {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
}

.theme-toggle .to-dark {
    display: none;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .theme-toggle .to-light {
        display: none;
    }

    :root:not([data-theme="dark"]) .theme-toggle .to-dark {
        display: inline-flex;
        gap: 0.45rem;
        align-items: center;
    }
}

:root[data-theme="light"] .theme-toggle .to-light {
    display: none;
}

:root[data-theme="light"] .theme-toggle .to-dark {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
}

/* Hero ------------------------------------------------------------------- */

.hero {
    position: relative;
    margin-top: -4.75rem;
    padding-top: 8rem;
    padding-bottom: 3.5rem;
    isolation: isolate;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(60% 55% at 15% 20%, rgb(245 150 170 / 12%), transparent 70%),
        radial-gradient(50% 50% at 85% 10%, rgb(131 204 210 / 10%), transparent 70%);
}

.hero-grid {
    display: grid;
    gap: 2.5rem;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
}

@media (width >= 60rem) {
    .hero-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 3rem;
        align-items: center;
    }
}

.eyebrow {
    margin: 0 0 0.6rem;
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0 0 0.35rem;
    font-size: clamp(2.75rem, 9vw, 4.25rem);
    font-weight: 700;
    letter-spacing: -0.035em;
}

.subtitle {
    max-width: 30rem;
    margin: 0 0 1.1rem;
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    font-weight: 500;
}

.lede {
    max-width: 34rem;
    margin: 0 0 1.75rem;
    color: var(--muted);
}

.cta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.button {
    display: inline-block;
    padding: 0.65rem 1.25rem;
    border: 1px solid var(--line-strong);
    border-radius: 0.5rem;
    background: var(--raised);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.button:hover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.button.primary {
    border-color: transparent;
    background: var(--accent);
    color: var(--on-accent);
}

.button.primary:hover {
    background: var(--accent-strong);
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.25rem;
    margin: 1.75rem 0 0;
    color: var(--faint);
    font-size: 0.85rem;
}

.meta span {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
}

.meta .tick {
    color: var(--accent);
}

/* Sections --------------------------------------------------------------- */

main {
    padding-block: 0 4rem;
}

section {
    padding-block: 3.5rem;
    border-top: 1px solid var(--line);
}

main > section:first-child {
    border-top: 0;
}

h2 {
    margin: 0 0 0.75rem;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -0.015em;
}

h2 .kicker {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
}

.section-lede {
    max-width: 44rem;
    margin: 0 0 1rem;
    color: var(--muted);
}

.section-lede code,
.note code {
    color: var(--text);
}

.note {
    margin: 1.75rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

/* Code ------------------------------------------------------------------- */

.code {
    margin: 0;
    border: 1px solid var(--code-line);
    border-radius: 0.75rem;
    background: var(--code-bg);
    overflow: hidden;
}

.code-head {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem 0.55rem 1rem;
    border-bottom: 1px solid var(--code-line);
    background: var(--code-head);
}

.code-head .name {
    color: var(--s-comment);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.code pre {
    margin: 0;
    padding: 1rem 1.15rem;
    overflow-x: auto;
    color: var(--s-string);
    font-size: 0.85rem;
    line-height: 1.7;
    tab-size: 2;
}

.copy {
    flex: none;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--code-line);
    border-radius: 0.35rem;
    background: transparent;
    color: var(--s-comment);
    font: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.copy:hover {
    border-color: var(--s-section);
    color: var(--s-section);
}

.copy[data-copied] {
    border-color: var(--s-section);
    color: var(--s-section);
}

/* Syntax, matching the scopes the editor grammar assigns. */

.s-section {
    color: var(--s-section);
    font-weight: 500;
}

.s-key {
    color: var(--s-key);
}

.s-string {
    color: var(--s-string);
}

.s-number {
    color: var(--s-number);
}

.s-keyword {
    color: var(--s-keyword);
}

.s-comment {
    color: var(--s-comment);
    font-style: italic;
}

.s-punct {
    color: var(--s-punct);
}

.s-error {
    color: var(--s-error);
}

.s-dim {
    color: var(--s-dim);
}

/* Cards ------------------------------------------------------------------ */

.cards {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    margin-top: 1.75rem;
}

.card {
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: var(--raised);
}

.card h3 {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

.card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.93rem;
}

.card p + p {
    margin-top: 0.6rem;
}

/* Prose beside code ------------------------------------------------------ */

.split {
    display: grid;
    gap: 1.25rem 2.5rem;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    margin-top: 1.75rem;
}

@media (width >= 54rem) {
    .split {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    }
}

.split + .split {
    margin-top: 2.5rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--line);
}

.split h3 {
    margin: 0 0 0.5rem;
}

.split p {
    margin: 0 0 0.75rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.split p:last-child {
    margin-bottom: 0;
}

.split p code {
    color: var(--text);
}

/* Value table ------------------------------------------------------------ */

.table-scroll {
    margin-top: 1.75rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

tr:last-child td {
    border-bottom: 0;
}

th {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
}

td:first-child {
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
}

td code {
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
    background: var(--accent-dim);
    color: var(--accent);
}

/* Packages --------------------------------------------------------------- */

.packages {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    margin-top: 1.75rem;
}

.package {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: var(--raised);
}

.package h3 {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
    margin: 0;
}

.package h3 .pkg {
    color: var(--muted);
    font-family: "IBM Plex Mono", ui-monospace, monospace;
    font-size: 0.8rem;
    font-weight: 400;
    overflow-wrap: anywhere;
}

.package p {
    flex: 1;
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.install {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.4rem 0.4rem 0.85rem;
    border: 1px solid var(--code-line);
    border-radius: 0.5rem;
    background: var(--code-bg);
}

.install code {
    color: var(--s-string);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.package .links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.85rem;
}

.package .links a {
    color: var(--muted);
}

/* CLI groups ------------------------------------------------------------- */

.groups {
    display: grid;
    gap: 1.75rem 2.5rem;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    margin-top: 2rem;
}

.group h3 {
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.group dl {
    margin: 0;
}

.group dt {
    margin-top: 0.85rem;
}

.group dt:first-child {
    margin-top: 0;
}

.group dt code {
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 0.82rem;
    overflow-wrap: anywhere;
}

.group dd {
    margin: 0.3rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Panel ------------------------------------------------------------------ */

.panel {
    padding: 2rem;
    border: 1px solid var(--line);
    border-radius: 0.9rem;
    background: var(--raised);
}

.checks {
    margin: 1.5rem 0 0;
    padding: 0;
    list-style: none;
}

.checks li {
    padding: 0.7rem 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.93rem;
}

.checks li strong {
    color: var(--text);
    font-weight: 500;
}

.warn {
    margin: 1.5rem 0 0;
    padding-left: 1rem;
    border-left: 2px solid var(--accent);
    color: var(--muted);
    font-size: 0.93rem;
}

.warn code {
    color: var(--text);
}

/* Footer ----------------------------------------------------------------- */

footer {
    border-top: 1px solid var(--line);
    background: var(--raised);
}

.footer-inner {
    padding-block: 2.5rem;
}

.footer-links {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.footer-links h4 {
    margin: 0 0 0.6rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.footer-links a {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 0.3em;
}

.colophon {
    max-width: 44rem;
    margin: 2rem 0 0;
    color: var(--faint);
    font-size: 0.8rem;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.swatches li {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    padding: 0.25rem 0.7rem 0.25rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 2rem;
    color: var(--faint);
    font-size: 0.72rem;
}

.swatches i {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 25%);
}

/* Error pages ------------------------------------------------------------ */

.centered {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100svh - 12rem);
    padding-block: 3rem 5rem;
}

.centered h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(2rem, 7vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.centered .code {
    max-width: 34rem;
    margin-top: 2rem;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
