/* =========================================================
 * Koike Lab — Foundation
 *
 * The whole site is composed around one image: a navy spine,
 * with two breathing arms (sky + violet). It's the lab's logo
 * read as a generative pattern — the two sides of inquiry
 * (engineering + cognitive science) cradling one question.
 *
 * This file holds only the substrate: tokens, reset, base type.
 * Components and motion live in assets/css/extra.css.
 * ========================================================= */

/* ---------- Tokens ---------- */
:root {
    /* Ink — navy from the logo, deepened just enough for body text. */
    --ink:         #002a3d;
    --ink-2:       #003f58;          /* logo navy */
    --ink-3:       #244b62;
    --ink-soft:    #4a6275;
    --ink-mute:    #8a9aa6;

    /* Paper — warm cream, breathable. */
    --paper:       #fbf7ec;
    --paper-2:     #f5efde;
    --paper-3:     #ffffff;
    --paper-warm:  #f6efda;
    --paper-deep:  #ede4cc;

    /* Rules. */
    --rule:        #002a3d;
    --rule-soft:   rgba(0,42,61,.14);
    --rule-fine:   rgba(0,42,61,.08);

    /* Brand pair — the two arms of the logo. */
    --sky:         #4c95bc;
    --sky-2:       #2f7596;
    --sky-soft:    rgba(76,149,188,.16);
    --violet:      #5e42ad;
    --violet-2:    #432a8c;
    --violet-soft: rgba(94,66,173,.14);

    /* Bud — the accent (green, the new growth). */
    --leaf:        #1f8a5e;
    --leaf-2:      #126a45;
    --leaf-soft:   rgba(31,138,94,.16);

    /* Occasional warmth (use sparingly). */
    --sun:         #d99b1c;
    --sun-2:       #b67d09;
    --berry:       #c4453a;

    /* Aliases for clarity in components. */
    --accent:      var(--leaf);
    --accent-2:    var(--leaf-2);
    --accent-soft: var(--leaf-soft);
    --accent-ink:  #ffffff;

    /* Shadows — soft, with a touch of navy in them. */
    --shadow-1:    0 1px 2px rgba(0,42,61,.06), 0 2px 6px rgba(0,42,61,.04);
    --shadow-2:    0 4px 12px rgba(0,42,61,.08), 0 12px 28px -10px rgba(0,42,61,.16);
    --shadow-3:    0 8px 24px rgba(0,42,61,.10), 0 24px 48px -16px rgba(0,42,61,.20);

    /* Legacy aliases the vendor partials still expect. */
    --primary:        var(--ink);
    --primary-light:  var(--ink-2);
    --accent-hover:   var(--accent-2);
    --purple:         var(--violet);
    --gold:           var(--sun);
    --text:           var(--ink);
    --text-light:     var(--ink-soft);
    --secondary:      var(--ink-soft);
    --bg:             var(--paper);
    --bg-alt:         var(--paper-2);
    --border:         var(--rule-soft);
    --darkMaincolor:  var(--accent);

    /* Type families — five roles, no more. */
    --font-sans:    "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --font-jp:      "Noto Sans JP", "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", sans-serif;
    --font-serif:   "Fraunces", "Noto Serif JP", Georgia, serif;
    --font-jp-serif:"Noto Serif JP", "Fraunces", "Hiragino Mincho ProN", serif;
    --font-mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    --font-hand:    "Caveat", "Comic Sans MS", cursive;
    --font-display: "Fraunces", "Noto Sans JP", "Inter", serif;

    /* Spacing — modular. */
    --s-0: 0.25rem;
    --s-1: 0.5rem;
    --s-2: 1rem;
    --s-3: 1.5rem;
    --s-4: 2rem;
    --s-5: 3rem;
    --s-6: 4.5rem;
    --s-7: 6.5rem;
    --s-8: 9rem;
    --s-9: 12rem;

    /* Page. */
    --shell-max: 1240px;
    --prose-max: 720px;
    --shell-pad: clamp(1.25rem, 4vw, 3rem);
    --header-h:  68px;

    /* Motion. */
    --ease:       cubic-bezier(.22, .9, .32, 1);
    --ease-out:   cubic-bezier(.16, 1, .3, 1);
    --ease-spring:cubic-bezier(.34, 1.56, .64, 1);
    --dur-fast:   180ms;
    --dur:        320ms;
    --dur-slow:   640ms;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.7;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

html:lang(ja),
html:lang(ja) body {
    font-family: var(--font-jp);
    letter-spacing: 0.005em;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    overflow-x: hidden;
    text-align: left;
    min-height: 100vh;
}

/* Soft ambient wash. Sky & violet halos breathe at the top, a leaf
   wash settles at the bottom — the logo's three accents diffused. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 8% -5%,  rgba(76,149,188,.12), transparent 60%),
        radial-gradient(ellipse 70% 50% at 95% 12%, rgba(94,66,173,.10), transparent 65%),
        radial-gradient(ellipse 120% 50% at 50% 110%, rgba(31,138,94,.06), transparent 60%);
}

::selection {
    background: var(--leaf);
    color: var(--accent-ink);
}

img {
    max-width: 100%;
    height: auto;
}

button {
    font: inherit;
    cursor: pointer;
}

/* ---------- Page shell ---------- */
.content {
    margin: 0 auto;
    max-width: var(--shell-max);
    padding: 0 var(--shell-pad);
}

main.content > section + section,
main.content > article + section,
main.content > section + article {
    margin-top: var(--s-7);
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    color: var(--ink);
    font-family: var(--font-display);
    font-variation-settings: "opsz" 120, "SOFT" 50, "WONK" 0;
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -0.018em;
    margin: 0 0 var(--s-3);
}

:lang(ja) h1,
:lang(ja) h2,
:lang(ja) h3,
:lang(ja) h4,
:lang(ja) h5,
:lang(ja) h6 {
    font-family: var(--font-jp-serif);
    font-weight: 900;
    letter-spacing: 0.005em;
    line-height: 1.4;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); }
h3 { font-size: clamp(1.2rem, 2vw, 1.4rem); }
h4 { font-size: 1.1rem; }
h5, h6 { font-size: 1rem; }

p {
    margin: 0 0 1.1em;
    line-height: 1.85;
    color: var(--ink);
}

em {
    font-family: var(--font-display);
    font-style: italic;
    font-variation-settings: "opsz" 14, "SOFT" 100, "WONK" 1;
    color: var(--violet-2);
    font-weight: 600;
}

:lang(ja) em {
    font-family: var(--font-jp);
    font-style: normal;
    color: var(--violet-2);
    background-image: linear-gradient(transparent 60%, rgba(94,66,173,.20) 60%);
    padding: 0 0.06em;
}

strong {
    font-weight: 700;
    color: var(--ink);
}

a {
    color: var(--ink);
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-position: 0 100%;
    background-repeat: no-repeat;
    background-size: 100% 1px;
    transition: color var(--dur) var(--ease),
                background-size var(--dur) var(--ease);
}

a:hover {
    color: var(--leaf-2);
    background-size: 100% 2px;
}

a.no-underline,
a.no-underline:hover {
    background-image: none;
}

/* A quiet divider: a faint rule with a small centered sprout (Font Awesome).
   The box is tall enough to hold the glyph; the rule is a 1px line painted as a
   centered background gradient so the sprout is never clipped to a hairline. */
hr {
    border: 0;
    height: 1.5rem;
    margin: var(--s-6) auto;
    width: 60%;
    max-width: 320px;
    position: relative;
    overflow: visible;
    background: linear-gradient(var(--rule-soft), var(--rule-soft)) center / 100% 1px no-repeat;
}
hr::after {
    content: "\f4d8";              /* Font Awesome solid "seedling" */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.85rem;
    color: var(--leaf);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--paper);
    padding: 0 0.7rem;
    line-height: 1;
}

ul, ol {
    margin: 0 0 1.25em;
    padding-left: 1.4em;
}

ul li, ol li {
    margin-bottom: 0.45em;
    line-height: 1.85;
}

ul.unstyled,
ol.unstyled {
    list-style: none;
    padding-left: 0;
}

blockquote {
    border: none;
    margin: 1.6em auto;
    padding: 0 0 0 1.4em;
    border-left: 3px solid var(--leaf);
    font-family: var(--font-display);
    font-variation-settings: "opsz" 144, "SOFT" 80, "WONK" 1;
    font-style: italic;
    font-size: 1.15rem;
    line-height: 1.65;
    color: var(--ink-2);
    max-width: 60ch;
}

:lang(ja) blockquote {
    font-family: var(--font-jp-serif);
    font-style: normal;
}

code {
    background: var(--paper-2);
    border: 1px solid var(--rule-soft);
    border-radius: 6px;
    padding: 0.1em 0.4em;
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--ink-2);
}

pre {
    background: #182b21;
    color: #e7e2cf;
    line-height: 1.55;
    overflow-x: auto;
    padding: 1.2em 1.4em;
    border-radius: 14px;
    border: none;
    box-shadow: var(--shadow-2);
    margin: 1.4em 0;
    max-width: 100%;
}

pre code {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 0.92em;
    padding: 0;
}

figure {
    margin: 1.5em 0;
}

figure img {
    border-radius: 12px;
    box-shadow: var(--shadow-1);
    max-height: 520px;
}

figure h4,
figcaption {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--ink-mute);
    margin: 0.6em 0 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

table {
    width: 100%;
    margin: 1.4em 0;
    border-collapse: collapse;
    font-size: 0.95rem;
    text-align: left;
}

table th,
table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--rule-soft);
    vertical-align: top;
}

table th {
    border-bottom: 2px solid var(--ink);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink);
}

table tr:hover td {
    background: var(--paper-warm);
}

/* ---------- Utility ---------- */
.muted {
    color: var(--ink-mute);
    font-size: 0.95rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.draft-label {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--berry);
    border: 1px solid currentColor;
    padding: 0.05em 0.45em;
    border-radius: 4px;
    margin-left: 0.5em;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    vertical-align: middle;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
