/* =============================================================================
   耕す経済 — Dark Tech Editorial

   Design language: Near-black bg + electric cyan accent + Space Grotesk display.
   Typography: Noto Sans JP (body/UI) + Space Grotesk (display/headings) +
               JetBrains Mono (labels/meta).

   Layout vocabulary:
      0. Tokens          — --td-* palette + typography scale
      1. Base            — box-sizing, html, body
      2. Typography      — headings, prose, drop-cap, ghost, links
      3. Scrollbar       — dark track + cyan hover thumb
      4. Skip/sr-only    — .sr-only + .focus:not-sr-only:focus
      5. .td-masthead    — sticky header with 3px cyan top line
      6. .td-shell       — responsive max-width container
      7. .td-rule        — rules + section breaks
      8. .td-kicker / .td-plate / .td-badge
      9. .td-meta        — dt/dd register grid
     10. .td-chapter-item
     11. .td-side-nav
     12. .td-dossier     — case-study cards
     13. .td-case-field
     14. .td-cookie
     15. Selection
     16. :focus-visible
     17. Print
     18. Reduced motion
   ============================================================================= */

/* ----- 0. Tokens --------------------------------------------------------- */

:root {
    /* Color palette */
    --td-bg:        #0D0D0F;
    --td-surface:   #161618;
    --td-surface-2: #1F1F23;
    --td-ink:       #E8E8F0;
    --td-ink-2:     #C4C4D4;
    --td-muted:     #707084;
    --td-rule:      rgba(232, 232, 240, 0.08);
    --td-rule-2:    rgba(232, 232, 240, 0.18);
    --td-cyan:      #00D4FF;
    --td-cyan-dk:   #00A3CC;
    --td-green:     #39FF7A;

    /* Layout */
    --td-shell-max:  1240px;
    --td-gutter-sm:  20px;
    --td-gutter-md:  32px;
    --td-gutter-lg:  48px;

    /* Typography */
    --td-font-body:    "Noto Sans JP", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
    --td-font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
    --td-font-ui:      "Noto Sans JP", ui-sans-serif, system-ui, sans-serif;
    --td-font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
}

/* ----- 1. Base ----------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background-color: var(--td-bg);
    color: var(--td-ink);
    font-family: var(--td-font-body);
    font-size: 15px;
    line-height: 1.85;
    overflow-x: hidden;
    word-break: normal;
    line-break: strict;
    overflow-wrap: break-word;
    hanging-punctuation: allow-end;
}

/* ----- 2. Typography ----------------------------------------------------- */

h1, h2, h3, h4 {
    font-family: var(--td-font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--td-ink);
    margin: 0;
}

p, dd, li {
    color: var(--td-ink-2);
    margin: 0;
}

.td-body-text {
    font-family: var(--td-font-body);
    font-size: 0.9375rem;
    line-height: 1.9;
    letter-spacing: 0.01em;
    color: var(--td-ink-2);
}

@media (min-width: 640px) {
    .td-body-text {
        font-size: 1rem;
        line-height: 1.95;
    }
}

/* Drop cap for opening paragraphs */
.td-drop-cap::first-letter {
    font-family: var(--td-font-display);
    font-size: 4rem;
    line-height: 1;
    float: left;
    margin-right: 0.5rem;
    margin-top: 0.2rem;
    color: var(--td-cyan);
    font-weight: 900;
}

/* Ghost chapter number — decorative background numeral */
.td-chapter-ghost {
    position: absolute;
    top: -0.8em;
    left: -0.1em;
    font-family: var(--td-font-display);
    font-size: 12rem;
    font-weight: 700;
    color: var(--td-surface-2);
    opacity: 0.5;
    z-index: -1;
    pointer-events: none;
    line-height: 1;
    user-select: none;
}

.font-mono,
code,
pre {
    font-family: var(--td-font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Links inside article/main prose */
article a,
main a:not(.td-cookie__accept):not(.td-cookie__link) {
    color: var(--td-ink-2);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.12s ease;
}

article a:hover,
main a:not(.td-cookie__accept):not(.td-cookie__link):hover {
    color: var(--td-cyan);
}

/* ----- 3. Scrollbar ------------------------------------------------------ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--td-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--td-surface-2);
    border: 2px solid var(--td-bg);
    border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--td-cyan);
}

html {
    scrollbar-color: var(--td-surface-2) var(--td-bg);
    scrollbar-width: thin;
}

/* ----- 4. Skip-to-main / sr-only ---------------------------------------- */

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

.focus\:not-sr-only:focus {
    position: fixed;
    top: 0;
    left: 0;
    width: auto;
    height: auto;
    padding: 10px 20px;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    z-index: 200;
    background: var(--td-cyan);
    color: var(--td-bg);
    font-family: var(--td-font-ui);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* ----- 5. Masthead ------------------------------------------------------- */

.td-masthead {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--td-bg);
    border-bottom: 1px solid var(--td-rule-2);
}

/* 3px cyan accent line at the very top of the masthead */
.td-masthead::before {
    content: "";
    display: block;
    height: 3px;
    background: var(--td-cyan);
}

.td-masthead__inner {
    max-width: var(--td-shell-max);
    margin: 0 auto;
    padding: 0 var(--td-gutter-sm);
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

@media (min-width: 640px) {
    .td-masthead__inner {
        padding: 0 var(--td-gutter-md);
    }
}

@media (min-width: 1024px) {
    .td-masthead__inner {
        padding: 0 var(--td-gutter-lg);
    }
}

.td-masthead__wordmark {
    display: flex;
    align-items: baseline;
    gap: 10px;
    text-decoration: none;
}

.td-masthead__latin {
    font-family: var(--td-font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--td-ink);
}

.td-masthead__jp {
    font-family: var(--td-font-body);
    font-size: 11px;
    color: var(--td-muted);
}

.td-masthead__issue {
    font-family: var(--td-font-mono);
    font-size: 10px;
    color: var(--td-muted);
}

/* ----- 6. Shell & layout helpers ----------------------------------------- */

.td-shell {
    max-width: var(--td-shell-max);
    margin: 0 auto;
    padding-left: var(--td-gutter-sm);
    padding-right: var(--td-gutter-sm);
}

@media (min-width: 640px) {
    .td-shell {
        padding-left: var(--td-gutter-md);
        padding-right: var(--td-gutter-md);
    }
}

@media (min-width: 1024px) {
    .td-shell {
        padding-left: var(--td-gutter-lg);
        padding-right: var(--td-gutter-lg);
    }
}

/* ----- 7. Rules & section breaks ----------------------------------------- */

.td-rule {
    display: block;
    width: 100%;
    height: 0;
    border: none;
    border-top: 1px solid var(--td-rule);
    margin: 0;
}

.td-rule--heavy {
    border-top-color: var(--td-rule-2);
}

.td-rule--cyan {
    border-top: 2px solid var(--td-cyan);
}

/* Section break — rule flanked by decorative marks */
.td-section-break {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 3rem 0;
    max-width: 56em;
}

.td-section-break::before,
.td-section-break::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--td-rule-2);
}

.td-section-break__mark {
    font-family: var(--td-font-mono);
    font-size: 9px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--td-muted);
}

/* ----- 8. Kicker / Plate / Badge ---------------------------------------- */

/* Kicker: cyan mono label above headings */
.td-kicker {
    display: block;
    font-family: var(--td-font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--td-cyan);
    margin-bottom: 10px;
}

/* Plate: numbered chapter tag */
.td-plate {
    display: inline-block;
    padding: 2px 8px;
    font-family: var(--td-font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    background: var(--td-surface-2);
    color: var(--td-cyan);
}

.td-plate--cyan {
    background: var(--td-cyan);
    color: var(--td-bg);
}

/* Badge: bordered label */
.td-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    font-family: var(--td-font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--td-ink);
    border: 1px solid var(--td-rule-2);
}

.td-badge__dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--td-cyan);
    flex-shrink: 0;
}

/* ----- 9. Meta register (dt/dd grid) ------------------------------------- */

.td-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 20px;
    font-family: var(--td-font-mono);
    font-size: 10.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.td-meta dt {
    color: var(--td-muted);
    padding: 2px 16px 2px 0;
    border-right: 1px solid var(--td-rule-2);
}

.td-meta dd {
    margin: 0;
    color: var(--td-ink-2);
    padding: 2px 0;
}

/* ----- 10. Chapter items ------------------------------------------------- */

.td-chapter-item {
    padding: 1.25rem 0 1.5rem;
    border-top: 1px solid var(--td-rule);
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 0 16px;
}

.td-chapter-item__num {
    font-family: var(--td-font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--td-muted);
    padding-top: 3px;
    line-height: 1.4;
}

.td-chapter-item__num--cyan {
    color: var(--td-cyan);
}

.td-chapter-item__content {
    min-width: 0;
}

.td-chapter-item__title {
    font-family: var(--td-font-ui);
    font-weight: 700;
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
    color: var(--td-ink);
    margin-bottom: 8px;
}

/* ----- 11. Side nav ------------------------------------------------------- */

.td-side-nav {
    display: none;
}

@media (min-width: 1024px) {
    .td-side-nav {
        display: block;
        position: sticky;
        top: 72px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        padding-right: 8px;
        border-right: 1px solid var(--td-rule-2);
    }

    .td-side-nav__label {
        font-family: var(--td-font-mono);
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.28em;
        text-transform: uppercase;
        color: var(--td-muted);
        padding: 0 0 8px 12px;
        display: block;
        border-bottom: 1px solid var(--td-rule);
        margin-bottom: 4px;
    }

    .td-side-nav ol {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .td-side-nav a {
        display: flex;
        align-items: baseline;
        gap: 10px;
        padding: 7px 10px 7px 12px;
        font-family: var(--td-font-body);
        font-size: 12px;
        letter-spacing: 0.02em;
        color: var(--td-muted);
        text-decoration: none;
        border-left: 2px solid transparent;
        transition: color 0.12s ease, border-color 0.12s ease;
        line-height: 1.3;
    }

    .td-side-nav a:hover,
    .td-side-nav a:focus-visible {
        color: var(--td-ink);
        border-left-color: var(--td-cyan);
    }

    .td-side-nav__num {
        font-family: var(--td-font-mono);
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.16em;
        color: var(--td-rule-2);
        flex-shrink: 0;
    }
}

/* ----- 12. Dossier cards ------------------------------------------------- */

.td-dossier {
    position: relative;
    background: var(--td-surface);
    border: 1px solid var(--td-rule-2);
    border-top: 2px solid var(--td-rule-2);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease, border-top-color 0.2s ease;
}

.td-dossier:hover {
    border-top-color: var(--td-cyan);
    box-shadow: 0 8px 24px -8px rgba(0, 212, 255, 0.15);
}

.td-dossier--featured {
    border-top: 2px solid var(--td-cyan);
}

.td-dossier__head {
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--td-rule);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.td-dossier__title {
    font-family: var(--td-font-ui);
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: -0.01em;
    line-height: 1.35;
    color: var(--td-ink);
}

.td-dossier__num {
    font-family: var(--td-font-mono);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--td-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.td-dossier__thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--td-surface-2);
    border-bottom: 1px solid var(--td-rule);
}

.td-dossier__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: brightness(0.75) contrast(1.1);
    transition: filter 0.4s ease, transform 0.5s ease;
}

.td-dossier:hover .td-dossier__thumb img {
    filter: brightness(0.9);
    transform: scale(1.03);
}

.td-dossier__body {
    padding: 14px 18px 18px;
    flex: 1;
}

/* ----- 13. Case fields --------------------------------------------------- */

.td-case-field {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 8px;
    padding: 8px 0;
    align-items: baseline;
}

.td-case-field + .td-case-field {
    border-top: 1px solid var(--td-rule);
}

.td-case-field__label {
    font-family: var(--td-font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--td-muted);
    line-height: 1.4;
}

.td-case-field__label--cyan {
    color: var(--td-cyan);
}

.td-case-field__body {
    font-family: var(--td-font-body);
    font-size: 12.5px;
    line-height: 1.75;
    color: var(--td-ink-2);
}

/* ----- 14. Cookie notice ------------------------------------------------- */

.td-cookie {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    background: var(--td-surface);
    border-top: 2px solid var(--td-cyan);
    opacity: 0;
    transform: translateY(100%);
    transition: opacity 0.35s ease, transform 0.35s ease;
    pointer-events: none;
}

.td-cookie.is-active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.td-cookie[hidden] {
    display: none;
}

.td-cookie__inner {
    max-width: var(--td-shell-max);
    margin: 0 auto;
    padding: 16px var(--td-gutter-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

@media (min-width: 720px) {
    .td-cookie__inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 24px;
        padding: 14px var(--td-gutter-md);
    }
}

.td-cookie__copy {
    min-width: 0;
    flex: 1;
}

.td-cookie__eyebrow {
    display: block;
    margin-bottom: 4px;
    font-family: var(--td-font-mono);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.24em;
    color: var(--td-cyan);
}

.td-cookie__body {
    margin: 0;
    font-family: var(--td-font-body);
    font-size: 12px;
    line-height: 1.7;
    color: var(--td-ink-2);
    max-width: 68ch;
}

.td-cookie__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 20px;
    align-items: center;
    flex-shrink: 0;
}

.td-cookie__link {
    font-family: var(--td-font-mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--td-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.12s ease;
}

.td-cookie__link:hover {
    color: var(--td-cyan);
}

.td-cookie__accept {
    padding: 9px 20px;
    background: var(--td-cyan);
    color: var(--td-bg);
    border: 0;
    font-family: var(--td-font-mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    cursor: pointer;
    transition: background 0.12s ease;
}

.td-cookie__accept:hover {
    background: var(--td-cyan-dk);
}

.td-cookie__accept:active {
    transform: scale(0.97);
}

.td-cookie__accept:focus-visible {
    outline: 2px solid var(--td-bg);
    outline-offset: 2px;
}

/* ----- 15. Selection ----------------------------------------------------- */

::selection {
    background: var(--td-cyan);
    color: var(--td-bg);
}

/* ----- 16. Focus visible ------------------------------------------------- */

:focus-visible {
    outline: 2px solid var(--td-cyan);
    outline-offset: 3px;
}

/* ----- 17. Print --------------------------------------------------------- */

@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }

    header,
    footer,
    .td-cookie,
    .td-side-nav,
    .td-section-break {
        display: none !important;
    }

    main {
        padding-top: 0 !important;
    }

    article a,
    main a {
        color: #000;
        text-decoration: underline;
    }

    .td-dossier {
        border: 1px solid #888;
        break-inside: avoid;
        background: #fff;
        box-shadow: none;
    }
}

/* ----- 18. Reduced motion ------------------------------------------------ */

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

    .td-cookie {
        transition: none;
    }

    .td-dossier:hover {
        box-shadow: none;
    }

    .td-dossier:hover .td-dossier__thumb img {
        transform: none;
    }
}
