/* ible.ai: the paper palette and Fraunces, as on the link-preview cards. */
:root {
    --paper: #f8fafc;
    --ink: #0f172a;
    --indigo: #6366f1;

    --bg: var(--paper);
    --fg: var(--ink);
    --fg-2: #334155;
    --fg-3: #64748b;
    --accent: var(--indigo);
    --accent-text: #4f46e5;
    --rule: rgba(15, 23, 42, 0.12);
    --rule-strong: rgba(15, 23, 42, 0.85);
    --wash: rgba(15, 23, 42, 0.05);
    --header-bg: rgba(248, 250, 252, 0.86);
    --portal-fill: var(--ink);
    --portal-fg: var(--paper);
    --portal-accent: #818cf8;
    --focus: var(--indigo);

    --serif: "Fraunces", Georgia, "Times New Roman", serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --content-width: 1120px;
    --gutter: 3rem;
    --header-height: 70px;
}

/* Dark mode is a neutral near-black, #0a0a0a as in graphible, with no blue in it. The theme script in
   the page's head sets data-theme from the saved choice or the system setting. */
:root[data-theme="dark"] {
    --bg: #0a0a0a;
    --fg: #ededed;
    --fg-2: #d4d4d4;
    --fg-3: #a3a3a3;
    --accent: #818cf8;
    --accent-text: #a5b4fc;
    --rule: rgba(250, 250, 250, 0.14);
    --rule-strong: rgba(250, 250, 250, 0.85);
    --wash: rgba(250, 250, 250, 0.08);
    --header-bg: rgba(10, 10, 10, 0.86);
    --portal-fill: #0a0a0a;
    --focus: #818cf8;
    color-scheme: dark;
}

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

html {
    scroll-behavior: smooth;
    background: var(--bg);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--serif);
    font-optical-sizing: auto;
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; }
code { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 200;
    padding: 0.6rem 0.9rem;
    background: var(--fg);
    color: var(--bg);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

/* The lockup is a symbol, so its colours come from here. */
.lockup { display: block; height: 100%; width: auto; overflow: visible; }
.lockup-hyphen { fill: var(--accent); }
.lockup-word { fill: currentColor; }

.nav-container,
.section-container,
.footer-container {
    width: min(calc(100% - var(--gutter)), var(--content-width));
    margin-inline: auto;
}

.arrow {
    display: inline-block;
    font-family: system-ui, sans-serif;
    font-size: 0.8em;
    transform: translateY(-0.05em);
}

/* Header */

.site-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 50;
    transition: background-color 200ms ease;
}

.site-header.is-scrolled,
.site-header.menu-open {
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

/* The lockup has no descenders, so its bottom edge is the baseline the nav sits on. */
.nav-container {
    padding: 26px 0 19px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.logo {
    display: block;
    height: 25px;
    color: var(--fg);
    text-decoration: none;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 2.25rem;
}

.site-nav a {
    color: var(--fg-2);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 160ms ease;
}

.site-nav a:hover,
.site-nav a:focus-visible { color: var(--fg); }

.menu-button { display: none; }

.nav-end {
    display: flex;
    align-items: baseline;
    gap: 1.5rem;
}

/* Shows a moon in light mode and a sun in dark mode: the theme it switches to. */
.theme-toggle {
    width: 34px;
    height: 34px;
    margin: -8px -8px -8px 0;
    padding: 0;
    display: inline-grid;
    place-items: center;
    align-self: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--fg-2);
    cursor: pointer;
    transition: color 160ms ease, background-color 160ms ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible { color: var(--fg); background: var(--wash); }

.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun,
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* Hero: sized against the viewport's height, so the projects stay in the first view. */

.hero {
    padding: calc(var(--header-height) + clamp(1rem, 4vh, 3.5rem)) 1.5rem clamp(1.75rem, 4.5vh, 3.25rem);
    display: grid;
    place-items: center;
    transition: opacity 450ms ease;
}

.hero-content {
    width: min(100%, 760px);
    text-align: center;
}

.hero h1 {
    margin: 0 0 clamp(0.5rem, 1.5vh, 1rem);
    font-size: clamp(3.25rem, min(8.6vw, 10.5vh), 6.75rem);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 0.95;
}

.mission {
    max-width: 760px;
    margin: 0 auto clamp(1.25rem, 3.4vh, 2.5rem);
    color: var(--fg-2);
    font-size: clamp(1.1rem, min(2vw, 2.7vh), 1.375rem);
    line-height: 1.45;
    text-wrap: balance;
}

/* The dictionary entry. */

.definition {
    max-width: 540px;
    margin: 0 auto;
    padding: clamp(0.8rem, 2vh, 1.4rem) 0 clamp(0.85rem, 2.1vh, 1.5rem);
    text-align: left;
    border-top: 1px solid var(--rule-strong);
}

.definition-title {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: clamp(0.5rem, 1.3vh, 0.9rem);
}

.definition-title strong {
    font-size: clamp(2rem, 4.6vh, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1;
}

.hyphen { color: var(--accent); }

.definition-title span:not(.hyphen) {
    color: var(--fg-3);
    font-size: 1.05rem;
}

.definition-body {
    display: grid;
    grid-template-columns: 4.75rem 1fr;
    gap: 1rem;
    color: var(--fg-2);
    font-size: clamp(0.92rem, 2vh, 1rem);
    line-height: 1.42;
}

.definition-body i { color: var(--fg-3); padding-top: 0.05em; }
.definition-body ol { margin: 0; padding-left: 1.3rem; }
.definition-body li { padding-left: 0.2rem; }
.definition-body li::marker { color: var(--fg-3); font-variant-numeric: tabular-nums; }
.definition-body li + li { margin-top: 0.2rem; }
.definition-body small { color: var(--fg-3); font-size: 0.9em; font-style: italic; }

/* Projects */

.projects {
    padding: clamp(1.75rem, 4.5vh, 3.5rem) 0 clamp(4rem, 10vh, 7rem);
    transition: opacity 450ms ease;
}

.projects h2 {
    margin: 0 0 clamp(1rem, 2.6vh, 1.75rem);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: clamp(2rem, 4vw, 3.5rem);
    row-gap: 3rem;
}

.project {
    position: relative;
    display: flex;
    flex-direction: column;
    padding-top: clamp(1rem, 2.3vh, 1.5rem);
}

.project-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: clamp(0.5rem, 1.4vh, 0.85rem);
}

.project h3 {
    margin: 0;
    font-size: clamp(1.9rem, 2.6vw, 2.35rem);
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1;
}

/* The title's letters are positioned by script; the link keeps their height. */
.project-title {
    position: relative;
    display: inline-block;
    height: 1.12em;
    min-width: 1ch;
    text-decoration: none;
    white-space: nowrap;
}

.title-word span {
    position: absolute;
    top: 0;
    left: 0;
    will-change: transform, opacity;
}

.title-word .title-hyphen,
.title-word .title-dot { color: var(--accent); }

.title-measure,
.suffix-measure {
    position: absolute;
    visibility: hidden;
    white-space: pre;
}

.project-source {
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    margin: -0.15rem -0.45rem 0 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--fg-3);
    transition: color 160ms ease, background-color 160ms ease;
}

.project-source svg { width: 1.25rem; height: 1.25rem; }
.project-source:hover,
.project-source:focus-visible { color: var(--fg); background: var(--wash); }

.project p {
    margin: 0;
    color: var(--fg-2);
    font-size: 1.04rem;
    line-height: 1.5;
}

.project .project-note {
    margin-top: 0.35rem;
    color: var(--fg-3);
    font-size: 0.97rem;
}

.project-foot {
    margin-top: auto;
    padding-top: clamp(1rem, 2.4vh, 1.5rem);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1.25rem;
}

/* A command field: the text stays selectable, and the button copies it. */
.install {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    border: 1px solid var(--rule);
    border-radius: 4px;
}

.install code {
    padding: 0.4rem 0.2rem 0.4rem 0.7rem;
    color: var(--fg-2);
    font-size: 0.8rem;
    white-space: nowrap;
    user-select: all;
}

.copy {
    position: relative;
    height: 2rem;
    min-width: 2rem;
    padding: 0 0.45rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--fg-3);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 160ms ease, background-color 160ms ease;
}

.copy:hover,
.copy:focus-visible { color: var(--fg); background: var(--wash); }
.copy svg { width: 1rem; height: 1rem; flex: none; }
.copy .check-icon { display: none; }
.copy.is-copied { color: var(--accent-text); }
.copy.is-copied .copy-icon { display: none; }
.copy.is-copied .check-icon { display: block; }

/* "Copied" floats below the button, so nothing around it moves. */
.copy-done {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    background: var(--fg);
    color: var(--bg);
    font-size: 0.78rem;
    line-height: 1.3;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-3px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.copy.is-copied .copy-done { opacity: 1; transform: none; }

.project-link {
    color: var(--fg-2);
    font-size: 0.95rem;
    text-decoration-color: var(--rule);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.3em;
    transition: color 160ms ease, text-decoration-color 160ms ease;
}

.project-link:hover,
.project-link:focus-visible { color: var(--fg); text-decoration-color: currentColor; }

/* Footer */

.site-footer {
    padding: 2.25rem 0 2.5rem;
}

.footer-container {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 2.25rem;
    align-items: baseline;
}

.site-footer .logo { height: 20px; justify-self: start; }

.site-footer a:not(.logo) {
    color: var(--fg-2);
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
}

.site-footer a:not(.logo):hover,
.site-footer a:not(.logo):focus-visible { color: var(--fg); }

.footer-container > span { color: var(--fg-3); font-size: 0.9rem; }

/* A cue to the projects, shown only while they are below the first screen. */

.scroll-cue {
    position: fixed;
    left: 50%;
    bottom: calc(1.1rem + env(safe-area-inset-bottom));
    z-index: 40;
    width: 2.75rem;
    height: 2.75rem;
    margin-left: -1.375rem;
    display: grid;
    place-items: center;
    border: 1px solid var(--rule);
    border-radius: 50%;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--fg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 300ms ease, transform 300ms ease, visibility 300ms;
}

.scroll-cue.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.scroll-cue svg { width: 1.25rem; height: 1.25rem; animation: cue 2.6s ease-in-out infinite; }

@keyframes cue {
    0%, 60%, 100% { transform: none; }
    30% { transform: translateY(3px); }
}

/* The portal into graphible: the hyphen draws across, then opens into a field. */

.is-entering .hero,
.is-entering .projects { opacity: 0.3; }

.portal {
    --x: 50vw;
    --y: 50vh;
    --reach: 240vmax;
    position: fixed;
    inset: 0;
    z-index: 100;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
}

.portal.is-active {
    visibility: visible;
    pointer-events: auto;
}

.portal-line,
.portal-fill {
    position: absolute;
    left: var(--x);
    top: var(--y);
    transform: translate(-50%, -50%) skewX(-13deg);
}

.portal-line {
    width: 1.75rem;
    height: clamp(6px, 0.7vmin, 10px);
    background: var(--accent);
    opacity: 0;
}

.portal-fill {
    width: 240vmax;
    height: 0;
    background: var(--portal-fill);
}

.portal.is-active .portal-line { animation: portal-line 1000ms cubic-bezier(0.45, 0, 0.2, 1) 100ms both; }
.portal.is-active .portal-fill { animation: portal-fill 650ms cubic-bezier(0.7, 0, 0.2, 1) 750ms forwards; }

@keyframes portal-line {
    0% { width: 1.75rem; opacity: 0; }
    8% { width: 1.75rem; opacity: 1; }
    65% { width: var(--reach); opacity: 1; }
    100% { width: var(--reach); opacity: 0; }
}

@keyframes portal-fill {
    from { height: clamp(6px, 0.7vmin, 10px); }
    to { height: 240vmax; }
}

.portal-word {
    position: absolute;
    inset: 50% 0 auto;
    margin: 0;
    color: var(--portal-fg);
    font-size: clamp(3.5rem, 11vw, 9rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1;
    opacity: 0;
    transition: opacity 450ms ease;
}

.portal.is-active .portal-word { opacity: 1; transition-delay: 1150ms; }

.suffix-word {
    position: absolute;
    left: 50%;
    top: -0.62em;
    white-space: nowrap;
}

.suffix-word span {
    position: absolute;
    top: 0;
    left: 0;
    will-change: transform, opacity;
}

.suffix-word .suffix-hyphen { color: var(--portal-accent); }

/* Narrower screens */

@media (max-width: 900px) {
    .project-grid { grid-template-columns: 1fr; }
    .project p { max-width: 36rem; }
}

@media (max-width: 640px) {
    :root { --gutter: 2rem; --header-height: 65px; }

    body { font-size: 16px; }

    .nav-container { padding: 10px 0; }
    .logo { height: 22px; }

    .menu-button {
        display: flex;
        align-items: center;
        gap: 0.65rem;
        min-height: 44px;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--fg);
        font: inherit;
        font-size: 0.95rem;
        font-weight: 500;
    }

    .menu-lines,
    .menu-lines::before {
        content: "";
        width: 18px;
        height: 1.5px;
        display: block;
        background: currentColor;
        transition: transform 200ms ease;
    }

    .menu-lines { transform: translateY(-3px); }
    .menu-lines::before { transform: translateY(6px); }
    .menu-button[aria-expanded="true"] .menu-lines { transform: rotate(45deg); }
    .menu-button[aria-expanded="true"] .menu-lines::before { transform: rotate(-90deg); }

    .site-nav {
        position: absolute;
        inset: 100% 0 auto;
        padding: 0.5rem 1rem 1rem;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--bg);
        border-bottom: 1px solid var(--rule);
    }

    .site-nav.is-open { display: flex; }
    .site-nav a { padding: 0.8rem 0; font-size: 1.1rem; }
    .site-nav a + a { border-top: 1px solid var(--rule); }

    /* The first screen is the hero alone; the cue points on to the projects. */
    .hero { min-height: 100svh; padding: calc(var(--header-height) + 1.5rem) 1rem 5rem; }
    .hero h1 { font-size: clamp(3.75rem, 19vw, 5rem); margin-bottom: 1rem; }
    .mission { margin-bottom: 2.25rem; }
    .definition { padding: 1.25rem 0 1.4rem; }
    .definition-title strong { font-size: 2.25rem; }
    .definition-body { grid-template-columns: 1fr; gap: 0.6rem; font-size: 0.97rem; }

    .projects { padding-top: 2.5rem; }
    .project-grid { row-gap: 2.75rem; }

    .footer-container { grid-template-columns: 1fr auto; gap: 1rem; }
    .footer-container > span { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
    }
    .scroll-cue svg { animation: none; }
}
