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

@font-face {
    font-family: 'Certa Sans';
    src: url('/fonts/certa-sans-medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: block;
}

:root {
    --paper: #F3F3EF;
    --ink: #000000;
    --ink-soft: #4a4a4a;
    --ink-faint: rgba(0, 0, 0, 0.45);
    --line: rgba(0, 0, 0, 0.16);
    --blue: #0000FF;
    --select: rgba(0, 0, 255, 0.18);

    --sans: 'Certa Sans', 'Inter', system-ui, sans-serif;
    --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

    --frame-gap: 15px;
    --frame-border: 5px;

    --pad-x: calc(var(--frame-gap) * 2 + var(--frame-border) + 26px);
    --pad-top: calc(var(--frame-gap) * 2 + var(--frame-border) + 44px + 26px);

    --down-mark-w: 40px;
    --down-mark-h: 92px;

    --safe-top: env(safe-area-inset-top);
    --safe-right: env(safe-area-inset-right);
    --safe-bottom: env(safe-area-inset-bottom);
    --safe-left: env(safe-area-inset-left);
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

::selection { background: var(--select); }

.frame {
    position: fixed;
    inset: var(--frame-gap);
    z-index: 6;
    border: var(--frame-border) solid var(--blue-pure);
    pointer-events: none;
}

.scene {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    padding: var(--pad-top) var(--pad-x) calc(var(--pad-x) - 10px);
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
}

.hero-name {
    margin: 0 0 -1em;
    padding-bottom: 1em;
    font-family: var(--sans);
    font-size: min(clamp(17px, 5.4vw, 76px), var(--tablo-max-name, 76px));
    font-weight: 500;
    line-height: 1.04;
    letter-spacing: -0.02em;
    hyphens: manual;
    cursor: pointer;
}

.hero-first { display: block; }

img.hero-face {
    height: 1.08em;
    margin: 0 0 0 0.16em;
    border-radius: 50%;
    align-self: center;
}

span.hero-face {
    position: relative;
    display: block;
    flex: none;
    width: 1.08em;
    height: 0;
    margin-left: 0.16em;
    align-self: baseline;
}

span.hero-face i {
    position: absolute;
    left: 0;
    bottom: -0.26em;
    width: 1.08em;
    height: 1.08em;
    background-position: center;
    background-size: 100% 100%;
    border-radius: 50%;
    transition: transform 0.56s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease-out;
    transition-delay: calc(var(--i, 0) * 18ms);
}

span.hero-face.broken i {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.6);
    opacity: 0;
    transition: transform 0.42s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.34s ease-in;
    transition-delay: 0s;
}

.tablo-board {
    display: block;
    width: max-content;
    max-width: 100%;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    font-weight: 500;
    font-variant-ligatures: none;
    font-kerning: none;
}

.tablo-board:focus-visible { outline: 2px solid var(--blue); outline-offset: 10px; }

.tablo-line {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    min-height: 1.04em;
}

.tablo-cell {
    display: block;
    flex: none;
    text-align: center;
    white-space: pre;
    font-style: normal;
    letter-spacing: normal;
}

.hero-foot {
    margin-top: auto;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.hero-down, .shots figcaption {
    color: var(--ink-faint);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.5;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.hero-down {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    text-decoration: none;
    transition: color 0.2s;
}

.hero-down:hover { color: var(--ink); }

.hero-down-mark {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: var(--down-mark-w);
    height: var(--down-mark-h);
    font-size: 26px;
    line-height: 1;
}

.hero-down-mark canvas { display: block; }

.bio-wrap {
    flex: 1;
    display: flex;
    align-items: center;
}

.bio {
    width: 100%;
    max-width: 1240px;
}

.bio-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 20px;
    margin-bottom: clamp(18px, 3vh, 34px);
}

.bio-title {
    margin: 0;
    font-size: clamp(22px, 2.6vw, 34px);
    font-weight: 500;
    letter-spacing: -0.01em;
}

.bio-hint {
    margin: 0;
    color: var(--ink-faint);
    font-family: var(--mono);
    font-size: 12px;
    transition: opacity 0.3s;
}

.bio-hint.gone { opacity: 0; }

html:not(.has-js) .bio-hint { display: none; }

.years {
    --year-col: 2.4em;
    --year-gap: clamp(14px, 1.6vw, 26px);
    margin: 0;
    padding: 0;
    list-style: none;
}

.year {
    border-top: 1px solid var(--line);
    font-size: clamp(15px, 1.55vw, 21px);
    line-height: 1.35;
}

.year:last-child { border-bottom: 1px solid var(--line); }

.year-head {
    display: grid;
    grid-template-columns: var(--year-col) 1fr;
    gap: 0 var(--year-gap);
    align-items: baseline;
    padding: clamp(8px, 1.2vh, 14px) 0;
    font-kerning: none;
    font-variant-ligatures: none;
}

.has-js .year-head { cursor: pointer; }

.year-head:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }

.year-num {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--ink-faint);
    transition: color 0.25s;
}

.year.is-open .year-num { color: var(--blue); }

html:not(.has-js) .year-num { color: var(--blue); }

.year-line b {
    font-weight: 500;
    color: var(--ink);
    background-image: linear-gradient(var(--blue), var(--blue));
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 0 1px;
    transition: background-size 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.year.is-open .year-line b { background-size: 100% 1px; }

.gain {
    display: inline-block;
    margin-left: 0.4em;
    padding: 0.06em 0.42em;
    font-style: normal;
    font-size: 0.82em;
    font-variant-numeric: tabular-nums;
    color: var(--blue);
    border: 1px solid rgb(var(--blue-rgb) / 0.45);
    white-space: nowrap;
    background-image: linear-gradient(var(--blue-pure), var(--blue-pure));
    background-repeat: no-repeat;
    background-size: 0 100%;
    transition: background-size 0.6s cubic-bezier(0.22, 1, 0.36, 1),
                color 0.3s, border-color 0.3s;
}

.year.is-open .gain {
    color: var(--on-accent);
    border-color: var(--blue-pure);
    background-size: 100% 100%;
}

.year-note {
    padding-bottom: clamp(9px, 1.4vh, 16px);
    padding-left: calc(var(--year-col) + var(--year-gap));
}

.has-js .year-note {
    display: grid;
    grid-template-rows: 0fr;
    padding-bottom: 0;
    transition: grid-template-rows 0.42s cubic-bezier(0.22, 1, 0.36, 1),
                padding-bottom 0.42s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.3s;
    opacity: 0;
}

.has-js .year.is-open .year-note {
    grid-template-rows: 1fr;
    padding-bottom: clamp(9px, 1.4vh, 16px);
    opacity: 1;
}

.year-note > p {
    min-height: 0;
    overflow: hidden;
    margin: 0;
    max-width: 76ch;
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: clamp(12px, 1.05vw, 14px);
    line-height: 1.55;
}

.bio-title.tablo,
.years.tablo .year-head { clip-path: inset(0 0 100% 0); }

.years.tablo .year.is-open .year-note { opacity: 0; }
.years.tablo .year.is-open .year-line b { background-size: 0 1px; }

.years.tablo .year.is-open .gain {
    color: var(--blue);
    border-color: rgb(var(--blue-rgb) / 0.45);
    background-size: 0 100%;
}

.bio-title.tablo.shown,
.years.tablo .year-head.shown {
    animation: bio-shutter 0.52s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes bio-shutter {
    from { clip-path: inset(0 0 100% 0); }
    to   { clip-path: inset(0 0 0 0); }
}

.roll-word { display: inline-block; }

.roll {
    display: inline-block;
    font-style: normal;
    transform-origin: 50% 62%;
    animation: bio-wind 0.46s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: var(--d, 0ms);
}

@keyframes bio-wind {
    from { transform: perspective(320px) translateY(0.42em) rotateX(-92deg); opacity: 0; }
    45%  { opacity: 1; }
    to   { transform: perspective(320px) translateY(0) rotateX(0deg); opacity: 1; }
}

.shots {
    position: relative;
    flex: none;
    width: clamp(120px, 13vw, 190px);
    margin: 0;
    text-align: right;
}

.shots img {
    display: block;
    width: 100%;
    aspect-ratio: 5 / 7;
    object-fit: cover;
    background: var(--line);
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.6s;
}

.shots img[data-i="1"],
.shots img[data-i="2"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

.shots img[data-i="0"] { position: relative; transform: rotate(-1.4deg); z-index: 3; }
.shots img[data-i="1"] { transform: rotate(2.6deg) translate(6px, 5px); opacity: 0.75; z-index: 2; }
.shots img[data-i="2"] { transform: rotate(-4.2deg) translate(-5px, 9px); opacity: 0.5; z-index: 1; }

.shots figcaption {
    position: relative;
    z-index: 4;
    margin-top: 20px;
    white-space: nowrap;
}

.skills-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.skills {
    width: 100%;
    max-width: 1240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.skills-controls { flex: none; }

.skills-btn {
    appearance: none;
    background: none;
    margin: 0;
    padding: 0.32em 0.9em;
    border: 1px solid rgb(var(--blue-rgb) / 0.45);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--blue);
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, border-color 0.2s, opacity 0.2s;
}

.skills-btn:hover:not(:disabled) {
    color: var(--on-accent);
    background-color: var(--blue-pure);
    border-color: var(--blue-pure);
}

.skills-btn:disabled { opacity: 0.4; cursor: default; }

.skills-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

.skills-fallback {
    margin: clamp(10px, 1.6vh, 20px) 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
}

.skills-fallback-name {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--ink-soft);
}

.skill-level {
    display: inline-block;
    margin-left: 0.5em;
    padding: 0.05em 0.5em;
    font-family: var(--mono);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--blue);
    border: 1px solid rgb(var(--blue-rgb) / 0.45);
}

.skills-ready .skills-fallback {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skills-stage {
    position: relative;
    flex: 1;
    min-height: clamp(240px, 40vh, 420px);
    margin-top: clamp(6px, 1.4vh, 16px);
}

.skills-stage:empty { display: none; }

.skills-canvas {
    display: block;
    position: absolute;
    top: 0;
}

.skills-canvas.is-clickable { cursor: pointer; }

.skills-label {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(-50%);
    width: max-content;
    max-width: 100px;
    text-align: center;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.35;
    color: var(--ink-soft);
    opacity: 0;
    transition: opacity 0.35s ease 0.25s;
    pointer-events: none;
}

.skills-label-name { display: block; }

.skills-label-num {
    display: inline-block;
    margin-top: 2px;
    padding: 0.02em 0.45em;
    color: var(--blue);
    border: 1px solid rgb(var(--blue-rgb) / 0.4);
}

.is-assembled .skills-label { opacity: 1; }

@media (max-width: 900px) {
    :root {
        --pad-x: calc(var(--frame-gap) * 2 + var(--frame-border) + 14px);
        --pad-top: calc(var(--frame-gap) * 2 + var(--frame-border) + 44px + 18px);
    }

    .shots { width: clamp(96px, 30vw, 130px); }

    .hero-down, .shots figcaption { font-size: 11px; letter-spacing: 0.02em; }

    .hero-down { gap: 8px; }
    .hero-down-mark { font-size: 22px; }

    .year-note { padding-left: 0; }

    .bio-wrap { display: block; }

    .skills-wrap { display: block; }
    .skills-stage { min-height: clamp(200px, 46vh, 320px); }

    .skills-label { max-width: 54px; font-size: 9.5px; line-height: 1.15; }
    .skills-label-num { padding: 0.02em 0.32em; }
}

@media (max-width: 600px) {
    :root {
        --down-mark-w: 34px;
        --down-mark-h: 76px;
    }

    .hero-name {
        margin-inline: calc(var(--frame-gap) + var(--frame-border) + 10px - var(--pad-x));
        font-size: min(clamp(17px, 7.6vw, 76px), var(--tablo-max-name, 76px));
    }
}

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

    span.hero-face i, .year-num, .year-line b,
    .gain, .shots img, .year-note { transition: none; }

    .skills-label { transition: none; }
}
