/* told.me

   One page: the addresses under told.me as a list set large, the two apps as two picture-book
   covers in their own colours, the open-source tools as rows with a screenshot each, and who
   makes them.

   Light is Mouton's day (wool white, ink the navy of Moly's night); dark is Moly's night.
   Two faces: a book face for addresses and headings, a plain one for everything read.
   The files named in url() get their version from the server at startup (src/assets.rs). */

@font-face {
    font-family: "Told Display";
    src: url(/static/fonts/hahmlet.woff2?v=cf3255e3ef21998f) format("woff2");
    font-weight: 700 800;
    font-display: swap;
}

@font-face {
    font-family: "Told Text";
    src: url(/static/fonts/pretendard.woff2?v=2a4de5e11a70330a) format("woff2");
    font-weight: 400 600;
    font-display: swap;
}

:root {
    color-scheme: light dark;
    --paper: #f3f4f9;
    --ink: #1e2342;
    /* Secondary text: 7.1:1 on the paper. */
    --ink-soft: #4b4f78;
    /* The ".told.me" of the lines nobody points at: there to be seen, not read. */
    --echo: #d2d4e4;
    --line: #dcdeea;
    --underline: #9a9dc9;
    --focus: #5a5eb4;
    /* What a screenshot lies on. */
    --mat: #e4e6f1;

    --display: "Told Display", "Iowan Old Style", "Palatino Linotype", "Apple SD Gothic Neo", "Noto Serif KR", Georgia, serif;
    --text: "Told Text", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", "Noto Sans KR", "Malgun Gothic", sans-serif;

    --gutter: clamp(1.25rem, 5vw, 3rem);
    --page: 70rem;
    --section: clamp(4.5rem, 10vw, 8rem);
    /* The three columns of the last section on a wide screen. */
    --first: 16rem;
    --last: 17.5rem;
    --column-gap: 2.5rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #15182f;
        --ink: #fffaf5;
        /* 9.6:1 on the paper. */
        --ink-soft: #c3c4e2;
        --echo: #343961;
        --line: #2b3055;
        --underline: #6e70ac;
        --focus: #b9bae3;
        --mat: #1e2342;
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding-inline: var(--gutter);
    background: var(--paper);
    color: var(--ink);
    font: 400 1.0625rem/1.6 var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Korean breaks between words, not inside them. */
:lang(ko) {
    word-break: keep-all;
    overflow-wrap: break-word;
}

h1,
h2,
h3,
p,
ul,
dl,
dd {
    margin: 0;
}

ul {
    padding: 0;
    list-style: none;
}

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

a {
    color: inherit;
    text-decoration: underline 1px var(--underline);
    text-underline-offset: 0.22em;
}

a:hover {
    text-decoration-color: currentColor;
}

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

.skip {
    position: absolute;
    left: var(--gutter);
    top: -4rem;
    padding: 0.5rem 0.875rem;
    border-radius: 0.5rem;
    background: var(--ink);
    color: var(--paper);
    text-decoration: none;
}

.skip:focus {
    top: 0.75rem;
}

.top,
main,
.maker {
    max-width: var(--page);
    margin-inline: auto;
}

/* ---- Header ---------------------------------------------------------------------------- */

.top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1.5rem;
    padding-block: 1.5rem;
}

.wordmark {
    font: 800 1.1875rem/1.2 var(--display);
    letter-spacing: -0.02em;
    text-decoration: none;
}

.languages {
    display: flex;
    gap: 1.25rem;
    font-size: 0.9375rem;
}

.languages a {
    color: var(--ink-soft);
    text-decoration-color: transparent;
}

.languages a:hover {
    color: var(--ink);
    text-decoration-color: currentColor;
}

.languages [aria-current] {
    font-weight: 600;
}

/* ---- The addresses --------------------------------------------------------------------- */

.hero {
    /* The size of the address list; the words beside it are placed by it on a wide screen. */
    --size: clamp(2rem, 10.5vw, 4.5rem);
    display: grid;
    gap: 2.5rem;
    padding-top: clamp(1.5rem, 5vw, 4rem);
}

.hero h1 {
    max-width: 16ch;
    font: 700 clamp(1.75rem, 3.4vw, 2.5rem)/1.18 var(--display);
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.hero-words p {
    max-width: 32ch;
    margin-top: 1rem;
    color: var(--ink-soft);
    font-size: 1.125rem;
    text-wrap: pretty;
}

/* Every line ends in the same ".told.me", so setting the lines flush right lines the names
   up on the dot. Lengths are in em of the list's own size: the bird scales with the letters. */
.addresses {
    --leading: 1.08;
    /* Room above the first line for the bird. */
    --headroom: 1.5em;
    /* The space between the apps and the open-source tools. */
    --group-gap: 0.32em;
    /* Which line the bird sits on, counted from 0, and whether that line is past the gap. */
    --row: 0;
    --past-gap: 0;
    position: relative;
    justify-self: end;
    padding-top: var(--headroom);
    font: 800 var(--size) / var(--leading) var(--display);
    letter-spacing: -0.025em;
    text-align: right;
    white-space: nowrap;
}

.addresses li.group {
    margin-top: var(--group-gap);
}

.addresses a {
    --dom: var(--echo);
    text-decoration: none;
}

.addresses .dom {
    color: var(--dom);
    transition: color 0.2s ease-out;
}

/* The first address is spelled out until another one is pointed at. */
.addresses li:first-child a {
    --dom: var(--ink);
}

.addresses:has(a:focus-visible) li:first-child a {
    --dom: var(--echo);
}

.addresses:has(a:focus-visible) li a:focus-visible {
    --dom: var(--ink);
}

/* The bird stands on the "ld" of the line that is spelled out. */
.bird {
    --width: 1.5em;
    position: absolute;
    z-index: 1;
    right: 1.62em;
    /* Its feet (the bottom edge of the picture) meet the top of the tall letters. */
    top: calc(var(--headroom) - var(--width) * 208 / 200 + 0.2em);
    width: var(--width);
    pointer-events: none;
    transform: translateY(calc(var(--row) * var(--leading) * 1em + var(--past-gap) * var(--group-gap)));
    transition: transform 0.5s cubic-bezier(0.3, 1.45, 0.45, 1);
}

.addresses:has(li:nth-child(2) a:focus-visible) { --row: 1; }
.addresses:has(li:nth-child(3) a:focus-visible) { --row: 2; --past-gap: 1; }
.addresses:has(li:nth-child(4) a:focus-visible) { --row: 3; --past-gap: 1; }
.addresses:has(li:nth-child(5) a:focus-visible) { --row: 4; --past-gap: 1; }
.addresses:has(li:nth-child(6) a:focus-visible) { --row: 5; --past-gap: 1; }
.addresses:has(li:nth-child(7) a:focus-visible) { --row: 6; --past-gap: 1; }
.addresses:has(li:nth-child(8) a:focus-visible) { --row: 7; --past-gap: 1; }

/* A pointer moves the bird as well; a finger does not hover, it follows the link. */
@media (hover: hover) {
    .addresses:has(a:hover) li:first-child a {
        --dom: var(--echo);
    }

    .addresses:has(a:hover) li a:hover {
        --dom: var(--ink);
    }

    .addresses:has(li:nth-child(1) a:hover) { --row: 0; --past-gap: 0; }
    .addresses:has(li:nth-child(2) a:hover) { --row: 1; --past-gap: 0; }
    .addresses:has(li:nth-child(3) a:hover) { --row: 2; --past-gap: 1; }
    .addresses:has(li:nth-child(4) a:hover) { --row: 3; --past-gap: 1; }
    .addresses:has(li:nth-child(5) a:hover) { --row: 4; --past-gap: 1; }
    .addresses:has(li:nth-child(6) a:hover) { --row: 5; --past-gap: 1; }
    .addresses:has(li:nth-child(7) a:hover) { --row: 6; --past-gap: 1; }
    .addresses:has(li:nth-child(8) a:hover) { --row: 7; --past-gap: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .bird,
    .addresses .dom {
        transition: none;
    }
}

@media (min-width: 60rem) {
    /* The list is as large as the width allows, and no larger than lets all of it show
       without scrolling in a laptop's window: its eight lines and the bird are 10.5 em tall. */
    .hero {
        --size: clamp(3.25rem, min(6.2vw, 7.5vh), 4.75rem);
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        column-gap: 3rem;
        padding-top: 0.5rem;
    }

    /* The words start level with the first address, under the bird's headroom. */
    .hero-words {
        padding-top: calc(var(--size) * 1.5 + 0.6rem);
    }
}

/* ---- Sections -------------------------------------------------------------------------- */

.apps,
.tools,
.maker {
    margin-top: var(--section);
}

h2 {
    font: 700 clamp(1.5rem, 2.6vw, 1.875rem)/1.2 var(--display);
    letter-spacing: -0.02em;
}

/* ---- The two apps ---------------------------------------------------------------------- */

.covers {
    display: grid;
    gap: 1.5rem;
    margin-top: 1.75rem;
}

@media (min-width: 52rem) {
    .covers {
        grid-template-columns: 1fr 1fr;
    }
}

/* A cover keeps its own colours in both themes: each is the field of its app. */
.cover {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: clamp(1.5rem, 4.2vw, 3rem);
    border-radius: 1.75rem;
    background: var(--field);
    color: var(--on);
    --focus: var(--on);
}

.cover-mouton {
    --field: #d9d2c4;
    --on: #2a2724;
    /* 5.3:1 on the field. */
    --on-soft: #544e46;
    --underline: rgb(42 39 36 / 0.4);
}

.cover-moly {
    --field: #1e2342;
    --on: #fffaf5;
    --on-soft: rgb(255 250 245 / 0.76);
    --underline: rgb(255 250 245 / 0.45);
}

@media (prefers-color-scheme: dark) {
    /* Moly's night is close to the page's: a hairline keeps its edge. */
    .cover-moly {
        box-shadow: inset 0 0 0 1px #343a5e;
    }
}

.cover-art {
    width: clamp(9.5rem, 24vw, 15rem);
    margin-bottom: clamp(1.25rem, 3vw, 2rem);
}

.cover h3 {
    font: 800 clamp(2rem, 4.4vw, 2.75rem)/1.1 var(--display);
    letter-spacing: -0.025em;
}

.cover .tagline {
    max-width: 30ch;
    margin-top: 0.75rem;
    font-size: 1.1875rem;
    font-weight: 600;
    line-height: 1.45;
    text-wrap: balance;
}

.cover p {
    max-width: 44ch;
    margin-top: 1rem;
    color: var(--on-soft);
    text-wrap: pretty;
}

.cover .tagline,
.cover .actions {
    color: var(--on);
}

.cover .terms {
    font-size: 0.9375rem;
}

.cover .actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.5rem;
    /* Pushed to the bottom, so the two covers end on one line however long their words are. */
    margin-top: auto;
    padding-top: 2rem;
    font-weight: 600;
}

.visit {
    padding: 0.7rem 1.35rem;
    border-radius: 99rem;
    background: var(--on);
    color: var(--field);
    text-decoration: none;
    transition: transform 0.15s ease-out;
}

.visit:hover {
    transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
    .visit {
        transition: none;
    }

    .visit:hover {
        transform: none;
    }
}

/* ---- The open-source tools ------------------------------------------------------------- */

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 1.25rem;
}

.section-head p {
    color: var(--ink-soft);
}

.tool-list {
    margin-top: 1.75rem;
    border-top: 1px solid var(--line);
}

/* A row: what the tool is, a picture of it, and its facts. */
.tool {
    display: grid;
    gap: 1.25rem;
    padding-block: clamp(2rem, 4.5vw, 2.75rem);
    border-bottom: 1px solid var(--line);
}

.tool-name {
    display: grid;
    grid-template-columns: 3.5rem minmax(0, 1fr);
    column-gap: 1rem;
    align-items: center;
    justify-items: start;
}

.tool-icon {
    grid-row: span 2;
    width: 3.5rem;
    height: 3.5rem;
}

.tool-name h3 {
    align-self: end;
    font: 700 1.5rem/1.2 var(--display);
    letter-spacing: -0.02em;
}

.tool-name a {
    align-self: start;
    color: var(--ink-soft);
    font-size: 0.9375rem;
}

.tool-words {
    max-width: 62ch;
}

.tool-words .tagline {
    font-weight: 600;
    text-wrap: balance;
}

.tool-words p + p {
    margin-top: 0.375rem;
    color: var(--ink-soft);
    text-wrap: pretty;
}

.tool-words ul {
    display: grid;
    gap: 0.375rem;
    margin-top: 1rem;
    font-size: 0.9375rem;
}

.tool-words li {
    position: relative;
    padding-left: 1.125rem;
    text-wrap: pretty;
}

.tool-words li::before {
    content: "";
    position: absolute;
    left: 0.125rem;
    top: 0.62em;
    width: 0.3125rem;
    height: 0.3125rem;
    border-radius: 50%;
    background: var(--underline);
}

/* The picture lies on a mat, which gives a light window an edge on the light page and a dark
   one an edge on the dark page. Two of the pictures are whole windows with their own corners. */
.tool-shot {
    max-width: 38rem;
    padding: clamp(0.75rem, 2.4vw, 1.25rem);
    border-radius: 1.25rem;
    background: var(--mat);
}

.tool-shot img {
    width: 100%;
    border-radius: 0.5rem;
}

.tool-facts {
    display: grid;
    gap: 0.25rem;
    font-size: 0.9375rem;
}

.tool-facts div {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: 0.75rem;
}

.tool-facts dt {
    color: var(--ink-soft);
}

/* On a wide screen the words keep the left and the picture the right. */
@media (min-width: 60rem) {
    .tool {
        --gap: 1.5rem;
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
        grid-template-rows: auto auto 1fr;
        column-gap: var(--gap);
        align-items: start;
    }

    .tool-name,
    .tool-words,
    .tool-facts {
        grid-column: 1;
    }

    .tool-words {
        max-width: 35rem;
    }

    .tool-shot {
        grid-column: 2;
        grid-row: 1 / -1;
        width: 100%;
        max-width: none;
    }
}

/* With more room the facts lie under both as one line of five columns, which stand in the same
   place in every row: three under the words, and two that start at the picture's left edge. */
@media (min-width: 74rem) {
    .tool {
        grid-template-rows: auto 1fr auto;
    }

    .tool-shot {
        grid-row: 1 / span 2;
    }

    .tool-facts {
        --under-words: calc((100% - var(--gap)) * 7 / 12 - 2 * var(--gap));
        --under-picture: calc((100% - var(--gap)) * 5 / 12 - var(--gap));
        grid-column: 1 / -1;
        grid-template-columns:
            calc(var(--under-words) * 0.36) calc(var(--under-words) * 0.32) calc(var(--under-words) * 0.32)
            calc(var(--under-picture) * 0.57) minmax(0, 1fr);
        gap: var(--gap);
        margin-top: 0.5rem;
    }

    .tool-facts div {
        display: block;
    }

    /* The source stays in the last column for the tool that has nothing to install. */
    .tool-facts div:last-child {
        grid-column: 5;
    }
}

/* ---- Who makes these ------------------------------------------------------------------- */

.maker {
    display: grid;
    gap: 1.25rem;
    padding-bottom: clamp(3rem, 8vw, 6rem);
}

.maker-words {
    display: grid;
    gap: 0.75rem;
    max-width: 62ch;
    color: var(--ink-soft);
    text-wrap: pretty;
}

/* The name of the works page stays on one line ("만든 것" is two words). */
.maker-words a {
    white-space: nowrap;
}

.maker-links {
    display: grid;
    gap: 0.25rem;
    align-content: start;
    font-size: 0.9375rem;
}

@media (min-width: 60rem) {
    .maker {
        grid-template-columns: var(--first) minmax(0, 1fr) var(--last);
        gap: 0;
    }

    .maker-words {
        padding-inline: var(--column-gap);
    }

    .maker-links {
        padding-top: 0.125rem;
    }
}

/* ---- 404 ------------------------------------------------------------------------------- */

.lost {
    display: grid;
    justify-items: start;
    gap: 1rem;
    padding-block: clamp(3rem, 12vw, 8rem);
}

.lost-bird {
    width: 7.5rem;
}

.lost h1 {
    max-width: 18ch;
    font: 800 clamp(2rem, 6vw, 3.5rem)/1.12 var(--display);
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.lost p {
    max-width: 44ch;
    color: var(--ink-soft);
}

.lost p:last-child {
    color: var(--ink);
    font-weight: 600;
}
