/* Hallmark · macrostructure: Index-First · theme: custom (warm-oat paper / vermillion accent, hue 70)
   · nav: none (single-page index) · footer: Ft2 inline single line
   · pre-emit critique: P4 H5 E5 S5 R5 V5
   · contrast: pass (40–41) · tokens: pass (48) · mobile: pass (34, 49, 50–57) */

/* ============================================================
   Tokens
   ============================================================ */

:root {
    /* Colour — light (default). Anchor hue 70, warm oat paper. */
    --color-paper:      oklch(97%   0.008 70);
    --color-paper-2:    oklch(94.5% 0.010 70);
    --color-rule:       oklch(87%   0.012 70);
    --color-muted:      oklch(44%   0.010 60);
    --color-ink:        oklch(21%   0.012 60);
    --color-accent:     oklch(56%   0.17  32);
    --color-accent-ink: oklch(98%   0.008 70);
    --color-focus:      oklch(56%   0.17  32);

    /* Type — 2+1: display (mono) · body (sans) · JP body */
    --font-display: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
    --font-body:    'Geist', 'Noto Sans JP', ui-sans-serif, sans-serif;

    /* Scale — perfect fourth (1.333) off a 15px base */
    --text-xs:  0.75rem;
    --text-sm:  0.8125rem;
    --text-md:  0.9375rem;
    --text-display: clamp(2.1rem, 6.4vw, 3.9rem);

    --lh-display: 1.04;
    --lh-body:    1.72;
    --lh-tight:   1.5;

    /* Space — 4pt base, named by role */
    --space-3xs: 0.125rem;
    --space-2xs: 0.25rem;
    --space-xs:  0.5rem;
    --space-sm:  0.75rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2.5rem;
    --space-2xl: 4rem;

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-micro: 120ms;
    --dur-short: 220ms;
    --dur-long:  420ms;

    /* Depth */
    --z-base:   1;
    --z-sticky: 200;

    /* Layout — asymmetric: wide left margin, content biased left */
    --measure: 64rem;
    --col-meta: 7rem;   /* 全セクション共通のメタ列幅 */
    --gutter-start: clamp(1.25rem, 11vw, 10rem);
    --gutter-end: 2rem;
}

/* Dark — same anchor hue, only lightness and chroma move. */
:root[data-theme='dark'] {
    --color-paper:      oklch(16%   0.010 70);
    --color-paper-2:    oklch(20%   0.012 70);
    --color-rule:       oklch(31%   0.010 70);
    --color-muted:      oklch(74%   0.008 60);
    --color-ink:        oklch(94%   0.008 80);
    --color-accent:     oklch(70%   0.145 34);
    --color-accent-ink: oklch(16%   0.010 70);
    --color-focus:      oklch(70%   0.145 34);
}

/* Dark mode compensates for the optical weight of light text on dark. */
:root[data-theme='dark'] body {
    font-weight: 350;
}

/* ============================================================
   Base
   ============================================================ */

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

html {
    overflow-x: clip;
    scroll-behavior: smooth;
}

body {
    overflow-x: clip; /* fallback for older Safari */
    background: var(--color-paper);
    color: var(--color-ink);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 400;
    line-height: var(--lh-body);
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--dur-short) var(--ease-out),
                color var(--dur-short) var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

.container {
    max-width: var(--measure);
    margin-inline: var(--gutter-start) var(--gutter-end);
}

a {
    color: inherit;
    text-decoration: none;
    text-underline-offset: 0.22em;
    text-decoration-thickness: 1px;
    transition: color var(--dur-micro) var(--ease-out),
                text-decoration-color var(--dur-micro) var(--ease-out);
}

a:hover {
    color: var(--color-accent);
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
}

a:active {
    color: var(--color-accent);
}

:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 3px;
    border-radius: 2px;
}

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

main {
    position: relative;
    z-index: var(--z-base);
}

/* Numerals in the meta columns align vertically. */
.works__date,
.article__date,
.article__likes,
.app__tech,
.info-table th,
.colophon {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ============================================================
   Theme toggle — understated, corner-docked
   ============================================================ */

.theme-toggle {
    position: fixed;
    inset-block-start: var(--space-lg);
    inset-inline-end: var(--space-lg);
    z-index: var(--z-sticky);
    display: grid;
    place-items: center;
    inline-size: 36px;
    block-size: 36px;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    transition: color var(--dur-micro) var(--ease-out),
                background-color var(--dur-micro) var(--ease-out),
                border-color var(--dur-micro) var(--ease-out),
                transform var(--dur-micro) var(--ease-out);
}

.theme-toggle:hover {
    color: var(--color-ink);
    background: var(--color-paper-2);
    border-color: var(--color-rule);
}

.theme-toggle:active {
    transform: translateY(1px);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.theme-toggle:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.theme-toggle svg {
    inline-size: 16px;
    block-size: 16px;
    display: block;
}

/* Show the icon for the mode you would switch *to*. */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none; }
:root[data-theme='dark'] .theme-toggle .icon-moon { display: none; }
:root[data-theme='dark'] .theme-toggle .icon-sun  { display: block; }

/* ============================================================
   Hero — left-biased, content-height, bottom-weighted
   ============================================================ */

.hero {
    padding-block: var(--space-xl) var(--space-2xl);
}

.hero__name {
    font-family: var(--font-display);
    font-size: var(--text-display);
    font-weight: 700;
    font-style: normal;
    line-height: var(--lh-display);
    letter-spacing: -0.035em;
    overflow-wrap: anywhere;
    min-width: 0;
    margin-block-end: var(--space-lg);
}

.hero__name .mark {
    color: var(--color-accent);
}


.hero__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md) var(--space-lg);
}

.hero__icons {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.hero__icon {
    display: flex;
    align-items: center;
    line-height: 1;
    color: var(--color-muted);
}

.hero__icon:hover {
    color: var(--color-accent);
}

.hero__icon svg {
    inline-size: 18px;
    block-size: 18px;
    display: block;
}

.hero__texts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md) var(--space-lg);
}

.hero__text-link {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1;
    white-space: nowrap;
    color: var(--color-muted);
}

.hero__text-link:hover {
    color: var(--color-accent);
}

/* ============================================================
   Sections — uneven rhythm, stacked single-column heads
   ============================================================ */

.section {
    padding-block: var(--space-lg) var(--space-xl);
}

.section--works   { padding-block: var(--space-xl) var(--space-xl); }
.section--apps    { padding-block: var(--space-lg) var(--space-lg); }
.section--articles{ padding-block: var(--space-xl) var(--space-2xl); }

.section__title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: 700;
    font-style: normal;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    line-height: 1.08;
    color: var(--color-muted);
    overflow-wrap: anywhere;
    min-width: 0;
    margin-block-end: var(--space-md);
}

/* The one accent mark per section: a 5px tick, well under the 3% budget. */
.section__title::before {
    content: '';
    inline-size: 5px;
    block-size: 5px;
    flex: 0 0 auto;
    background: var(--color-accent);
}

/* ============================================================
   About
   ============================================================ */

.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table tr {
    border-block-end: 1px solid var(--color-rule);
}

.info-table tr:first-child {
    border-block-start: 1px solid var(--color-rule);
}

.info-table th {
    text-align: start;
    padding: var(--space-sm) var(--space-lg) var(--space-sm) 0;
    font-size: var(--text-xs);
    font-weight: 400;
    color: var(--color-muted);
    width: var(--col-meta);
    white-space: nowrap;
    vertical-align: top;
}

.info-table td {
    padding: var(--space-sm) 0;
    font-size: var(--text-md);
    line-height: var(--lh-tight);
}

.info-table td a {
    text-decoration: underline;
    text-decoration-color: var(--color-rule);
}

/* ============================================================
   Index rows — date in the left margin, content right
   ============================================================ */

.index-list {
    list-style: none;
}

.index-list > li {
    border-block-end: 1px solid var(--color-rule);
    display: grid;
    gap: var(--space-2xs) var(--space-lg);
}

.works-list > li {
    grid-template-columns: var(--col-meta) minmax(0, 1fr);
    align-items: baseline;
    padding-block: var(--space-sm);
}

.works__date {
    font-size: var(--text-xs);
    color: var(--color-muted);
    white-space: nowrap;
}

.works__title {
    font-size: var(--text-md);
    font-weight: 600;
    line-height: var(--lh-tight);
}


/* アプリ名は長さがまちまちなので固定メタ列に入れず、
   名前を可変幅・技術を右端に寄せて罫線の両端で揃える */
.apps-list > li {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    padding-block: var(--space-sm);
}

.app__name {
    font-size: var(--text-md);
    font-weight: 600;
    overflow-wrap: anywhere;
    min-width: 0;
}

.app__tech {
    font-size: var(--text-xs);
    color: var(--color-muted);
    text-align: end;
}

.articles-list > li {
    grid-template-columns: var(--col-meta) minmax(0, 1fr);
    align-items: baseline;
    padding-block: var(--space-sm);
}

.article__date {
    font-size: var(--text-xs);
    color: var(--color-muted);
    white-space: nowrap;
}

.article__body {
    font-size: var(--text-md);
    line-height: var(--lh-tight);
}

.article__likes {
    font-size: var(--text-xs);
    color: var(--color-muted);
    margin-inline-start: var(--space-xs);
    white-space: nowrap;
}

/* ============================================================
   Footer — Ft2, one line
   ============================================================ */

.colophon {
    padding-block: var(--space-lg) var(--space-2xl);
    font-size: var(--text-xs);
    color: var(--color-muted);
    border-block-start: 1px solid var(--color-rule);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-md);
    line-height: 1.4;
}

/* ============================================================
   One orchestrated entrance
   ============================================================ */

.reveal {
    opacity: 0;
    transform: translateY(8px);
    animation: reveal var(--dur-long) var(--ease-out) forwards;
    animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes reveal {
    to { opacity: 1; transform: none; }
}

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

    .reveal {
        transform: none;
        animation: reveal-reduced 150ms linear forwards;
    }

    @keyframes reveal-reduced {
        to { opacity: 1; transform: none; }
    }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 48rem) {
    :root {
        --gutter-start: 1.25rem;
        --gutter-end: 1.25rem;
        /* リストは1カラムに畳まれるので、この上書きが効くのは About の表のみ */
        --col-meta: 5.5rem;
    }

    .hero {
        padding-block: var(--space-xl) var(--space-2xl);
    }

    .theme-toggle {
        inset-block-start: var(--space-md);
        inset-inline-end: var(--space-md);
    }

    .works-list > li,
    .apps-list > li,
    .articles-list > li {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-3xs);
    }

    .app__tech {
        text-align: start;
    }

    .info-table th {
        padding-inline-end: var(--space-sm);
    }
}
