/* Homepage, part 1: the shell. Paper, ink, and one shelf: six things I made, grouped
   by where they live (App Store, YouTube, Udemy). Each keeps its own look, on the
   shelf here and in its section below (worlds.css). */

:root {
    --paper: #f2efe8;
    --ink: #131313;
    --hot: #ff4b1f;
    --pad: clamp(16px, 2.8vw, 44px);
    --sans: 'Bricolage Grotesque', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'DM Mono', ui-monospace, Menlo, monospace;
    --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

html {
    background: var(--paper);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.55;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

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

a {
    color: inherit;
}

ul, ol {
    list-style: none;
}

/* ---------- top bar: inverts against whatever is under it ---------- */

.bar {
    position: fixed;
    z-index: 30;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    padding: max(16px, env(safe-area-inset-top)) var(--pad) 12px;
    color: #fff;
    mix-blend-mode: difference;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    pointer-events: none;
}

.bar a {
    pointer-events: auto;
    text-decoration: none;
}

.bar-home {
    white-space: nowrap;
    font-weight: 700;
    letter-spacing: -0.02em;
    transition: opacity 0.3s;
}

.is-top .bar-home {
    opacity: 0;
}

.bar-nav {
    display: flex;
    white-space: nowrap;
    gap: clamp(14px, 2vw, 30px);
}

.bar-nav a {
    padding-bottom: 3px;
    border-bottom: 1.5px solid transparent;
    transition: border-color 0.2s;
}

.bar-nav a:hover,
.bar-nav a:focus-visible,
.bar-nav a[aria-current] {
    border-color: currentColor;
    outline: none;
}

/* ---------- hero: the name, one sentence, the shelf ---------- */

.hero {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: clamp(18px, 3.2vh, 34px);
    height: 100vh;
    height: 100svh;
    min-height: 620px;
    padding: clamp(58px, 9vh, 84px) var(--pad) clamp(16px, 2.6vh, 28px);
}

.hero-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: clamp(20px, 4vw, 70px);
}

.hero h1 {
    margin-left: -0.045em;
    font-weight: 800;
    font-size: clamp(60px, 12.9vw, 248px);
    line-height: 0.8;
    letter-spacing: -0.062em;
    font-variation-settings: 'opsz' 96;
    white-space: nowrap;
    padding-bottom: 0.07em;        /* room for the cedilla of the ş above the shelf */
    animation: rise 0.9s var(--ease) both;
}

.hero-head p {
    flex: 0 1 31ch;
    padding-bottom: 0.35em;
    font-size: clamp(15px, 1.32vw, 21px);
    font-weight: 500;
    line-height: 1.32;
    letter-spacing: -0.01em;
    text-wrap: balance;
    animation: rise 0.9s var(--ease) 0.12s both;
}

/* ---------- the shelf ---------- */

.shelf {
    display: flex;
    gap: 12px;
    min-height: 0;
}

.group {
    display: flex;
    flex-direction: column;
    gap: 9px;
    flex: 1 1 0;
    min-width: 0;
    transition: flex-grow 0.65s var(--ease);
}

/* a group is as wide as the things in it; it grows with the one that opens */
.group[data-size="3"] { flex-grow: 3; }
.group[data-size="2"] { flex-grow: 2; }
.group[data-size="3"].has-open { flex-grow: 5.4; }
.group[data-size="2"].has-open { flex-grow: 4.4; }
.group[data-size="1"].has-open { flex-grow: 3.4; }

.group-name {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--mono);
    font-weight: 500;
    font-size: 13px;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.group-name::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hot);
}

.group-name::after {
    content: '';
    flex: 1;
    height: 1.5px;
    background: var(--ink);
}

.row {
    display: flex;
    flex: 1;
    gap: 12px;
    min-height: 0;
}

.spine {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    container-type: size;
    border: 1.5px solid var(--ink);
    border-radius: 18px;
    background: var(--bg);
    color: var(--fg);
    text-decoration: none;
    transition: flex-grow 0.65s var(--ease);
    animation: spine-in 0.9s var(--ease) both;
}

.group:nth-child(1) .spine:nth-child(1) { animation-delay: 0.18s; }
.group:nth-child(1) .spine:nth-child(2) { animation-delay: 0.24s; }
.group:nth-child(1) .spine:nth-child(3) { animation-delay: 0.3s; }
.group:nth-child(2) .spine:nth-child(1) { animation-delay: 0.36s; }
.group:nth-child(2) .spine:nth-child(2) { animation-delay: 0.42s; }
.group:nth-child(3) .spine:nth-child(1) { animation-delay: 0.48s; }

.spine.is-open {
    flex-grow: 3.4;
}

.spine:focus-visible {
    outline: 3px solid var(--hot);
    outline-offset: 2px;
}

.spine-kind {
    position: absolute;
    z-index: 2;
    left: 16px;
    top: 15px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* the title runs up the spine, like on a book */
.spine-title {
    position: absolute;
    z-index: 2;
    left: 13px;
    bottom: 16px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 9.6cqh;
    line-height: 1;
    white-space: nowrap;
}

.spine-more {
    position: absolute;
    z-index: 2;
    left: calc(9.6cqh + 34px);
    top: 44px;
    width: min(250px, 60cqw);
    font-size: clamp(15px, 1.2vw, 19px);
    font-weight: 500;
    line-height: 1.22;
    letter-spacing: -0.01em;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s, transform 0.4s var(--ease);
}

.spine-more b {
    display: block;
    margin-top: 12px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.spine-more b::after {
    content: ' →';
}

.spine.is-open .spine-more {
    opacity: 1;
    transform: none;
    transition-delay: 0.22s;
}

/* what is inside: screens or covers, most of them hidden until the spine opens */
.spine-art {
    position: absolute;
    left: calc(9.6cqh + 34px);
    bottom: -8cqh;
    display: flex;
    gap: 12px;
    height: 70cqh;
    transform: translateY(5cqh);
    transition: transform 0.65s var(--ease);
}

.spine.is-open .spine-art {
    transform: none;
}

.spine-art img {
    width: auto;
    height: 100%;
    max-width: none;
    border-radius: 14px;
}

.spine-thumbs {
    display: grid;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    grid-auto-flow: column;
    gap: 10px;
    height: 54cqh;
    bottom: 5cqh;
}

.spine-thumbs img {
    aspect-ratio: 16 / 9;
    border-radius: 8px;
}

.spine-thumbs .tile {
    aspect-ratio: 1;
    object-fit: cover;
}

.spine-cover {
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    height: 64cqh;
    transform: none;
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%);
    mask-image: linear-gradient(180deg, transparent, #000 22%);
}

.spine-cover img {
    width: 100%;
    object-fit: cover;
    object-position: 0% 50%;
    border-radius: 0;
    transition: object-position 0.65s var(--ease);
}

.spine.is-open .spine-cover img {
    object-position: 22% 50%;
}

/* six looks */
.spine-vize {
    --bg: #244a3b;
    --fg: #f4e7bd;
    background-image: var(--noise);
    background-blend-mode: soft-light;
}

.spine-vize .spine-title {
    font-family: 'Pixelify Sans', var(--mono);
    font-weight: 700;
    text-shadow: 0.06em 0.06em 0 #14261f;
}

.spine-vize .spine-art img {
    border: 3px solid #14261f;
    border-radius: 0;
    box-shadow: 6px 6px 0 #14261f;
}

.spine-tonmi {
    --fg: #3a2a2a;
    background: linear-gradient(180deg, #bfe3ff 0%, #e3f2ff 62%, #fff6e3 100%);
}

.spine-tonmi .spine-title {
    font-family: 'Fredoka', var(--sans);
    font-weight: 600;
}

.spine-tonmi .spine-art img {
    border: 4px solid #3a2a2a;
    border-radius: 22px;
}

.spine-leaf {
    --fg: #364537;
    background:
        linear-gradient(rgba(70, 95, 70, 0.09) 1px, transparent 1px) 0 0 / 26px 26px,
        linear-gradient(90deg, rgba(70, 95, 70, 0.09) 1px, transparent 1px) 0 0 / 26px 26px,
        radial-gradient(ellipse 90% 50% at 60% 30%, #d6e9c4, transparent 70%),
        #f3f1e3;
}

.spine-leaf .spine-title {
    font-family: 'Mynerve', cursive;
    font-size: 11cqh;
}

.spine-leaf .spine-art img {
    border: 1.5px solid #5a6b5a;
    border-radius: 20px;
}

.spine-hissera {
    --fg: #f8f7ff;
    background:
        radial-gradient(ellipse 90% 45% at 20% 12%, rgba(154, 125, 255, 0.5), transparent 70%),
        radial-gradient(ellipse 80% 40% at 90% 95%, rgba(21, 190, 151, 0.3), transparent 70%),
        #12153a;
}

.spine-hissera .spine-title {
    font-family: 'Montserrat', var(--sans);
    font-weight: 800;
    letter-spacing: -0.045em;
}

.spine-strange {
    --fg: #ece2cb;
    background:
        radial-gradient(ellipse 100% 45% at 60% 70%, rgba(210, 174, 102, 0.3), transparent 70%),
        #0d0b0e;
}

.spine-strange .spine-title {
    font-family: var(--serif);
    font-weight: 300;
    font-style: italic;
    letter-spacing: -0.03em;
    font-variation-settings: 'opsz' 144;
}

.spine-strange .spine-thumbs img {
    padding: 3px;
    border-radius: 0;
    background: linear-gradient(135deg, #7a5a22, #e6c97c 30%, #8a6a2c 55%, #dcbb6a 80%, #6a4d1c);
}

.spine-udemy {
    --bg: #f1d078;
    --fg: #15171c;
}

/* the course's long title sits flat above the slide instead of running up it */
.spine-udemy .spine-title {
    left: 16px;
    top: 42px;
    bottom: auto;
    width: min-content;
    writing-mode: horizontal-tb;
    transform: none;
    white-space: normal;
    font-family: 'Archivo', var(--sans);
    font-stretch: 125%;
    font-weight: 800;
    font-size: clamp(13px, min(5.4cqh, 16.5cqw), 27px);
    line-height: 0.96;
    letter-spacing: -0.035em;
}

.spine-udemy .spine-more {
    left: 170px;
    top: 42px;
}

/* stepping inside: the spine's colour floods the window, then the section is there */
.flood {
    position: fixed;
    z-index: 40;
    border-radius: 18px;
    transition:
        left 0.55s cubic-bezier(0.7, 0, 0.2, 1), top 0.55s cubic-bezier(0.7, 0, 0.2, 1),
        width 0.55s cubic-bezier(0.7, 0, 0.2, 1), height 0.55s cubic-bezier(0.7, 0, 0.2, 1),
        border-radius 0.55s, opacity 0.45s;
}

/* phones: the shelf turns on its side, one band per thing */
@media (max-width: 760px) {
    .bar {
        justify-content: flex-end;
        font-size: 14px;
    }

    .bar-home {
        display: none;
    }

    .hero {
        display: block;
        height: auto;
        min-height: 0;
        padding-top: 78px;
    }

    .hero-head {
        display: block;
    }

    .hero h1 {
        font-size: 19.2vw;
    }

    .hero-head p {
        margin-top: 18px;
        padding: 0;
        font-size: 17px;
    }

    .shelf {
        flex-direction: column;
        gap: 22px;
        margin-top: 30px;
    }

    .group,
    .group.has-open {
        flex: none;
    }

    .row {
        flex-direction: column;
        gap: 9px;
    }

    .spine,
    .spine.is-open {
        flex: none;
        height: 104px;
        border-radius: 16px;
    }

    .spine-title,
    .spine-leaf .spine-title,
    .spine-udemy .spine-title {
        left: 16px;
        bottom: 14px;
        writing-mode: horizontal-tb;
        transform: none;
        font-size: 30px;
    }

    .spine-udemy .spine-title {
        top: auto;
        width: 46%;
        font-size: 21px;
    }

    .spine-more {
        display: none;
    }

    .spine-art,
    .spine.is-open .spine-art {
        left: auto;
        right: -24px;
        top: 12px;
        bottom: auto;
        height: 230px;
        gap: 8px;
        transform: rotate(4deg);
    }

    .spine-art img:nth-child(n + 3) {
        display: none;
    }

    .spine-thumbs,
    .spine.is-open .spine-thumbs {
        grid-template-rows: minmax(0, 1fr);
        right: -70px;
        top: 14px;
        height: 76px;
        transform: none;
    }

    .spine-cover,
    .spine.is-open .spine-cover {
        left: 42%;
        right: 0;
        top: 0;
        height: 100%;
        transform: none;
        -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%);
        mask-image: linear-gradient(90deg, transparent, #000 40%);
    }

    .spine-cover img {
        object-position: 30% 50%;
    }
}

/* ---------- the end of the shelf ---------- */

.off {
    border-top: 1.5px solid var(--ink);
    background: var(--paper);
}

.off-in {
    padding: clamp(70px, 13vh, 160px) var(--pad) clamp(36px, 6vh, 60px);
}

.off h2 {
    margin-left: -0.04em;
    font-weight: 800;
    font-size: clamp(46px, 9.4vw, 180px);
    line-height: 0.84;
    letter-spacing: -0.058em;
    font-variation-settings: 'opsz' 96;
    text-wrap: balance;
}

.off h2 span {
    color: var(--hot);
}

/* the message form: three ruled lines to write on */
.write {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    gap: clamp(20px, 4vw, 70px);
    margin-top: clamp(44px, 9vh, 100px);
}

.write-note {
    max-width: 17em;
    font-size: clamp(17px, 1.5vw, 23px);
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.write-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(22px, 3.4vh, 34px) clamp(14px, 2vw, 32px);
}

.field {
    display: block;
}

.field-wide,
.write-send {
    grid-column: 1 / -1;
}

.field span {
    display: block;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.field input,
.field textarea {
    display: block;
    width: 100%;
    padding: 10px 0 12px;
    border: 0;
    border-bottom: 1.5px solid var(--ink);
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: clamp(19px, 1.9vw, 28px);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.025em;
    outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.field textarea {
    min-height: 4.2em;
    resize: vertical;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--hot);
    box-shadow: 0 1.5px 0 var(--hot);
}

.field:focus-within span {
    color: var(--hot);
}

.field.is-wrong input,
.field.is-wrong textarea {
    border-bottom-style: dashed;
    border-color: var(--hot);
}

/* not for people: scripts fill it in and are ignored */
.field-trap {
    position: absolute;
    left: -200vw;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.write-send {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 24px;
}

.write-send button {
    padding: 16px 30px 17px;
    border: 1.5px solid var(--ink);
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font: inherit;
    font-size: clamp(17px, 1.4vw, 21px);
    font-weight: 700;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.write-send button:hover,
.write-send button:focus-visible {
    border-color: var(--hot);
    background: var(--hot);
    outline: none;
}

.write-send button:active {
    transform: translateY(1px);
}

.write-send button:disabled {
    opacity: 0.5;
    cursor: default;
}

.write-status {
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 0.03em;
}

.write-status.is-bad {
    color: #c22a05;
}

.off-links {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0 clamp(14px, 2vw, 32px);
    margin-top: clamp(50px, 10vh, 110px);
}

.off-links a {
    display: block;
    padding: 16px 0 26px;
    border-top: 1.5px solid var(--ink);
    font-size: clamp(18px, 1.5vw, 23px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
}

.off-links span {
    display: block;
    margin-bottom: 10px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.off-links a:hover,
.off-links a:focus-visible {
    color: var(--hot);
    border-color: var(--hot);
    outline: none;
}

.off-small {
    margin-top: 30px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.04em;
}

@media (max-width: 900px) {
    .write {
        grid-template-columns: minmax(0, 1fr);
    }

    .off-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .write-form {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- motion ---------- */

@keyframes rise {
    from { opacity: 0; transform: translateY(22px); }
    to { opacity: 1; transform: none; }
}

@keyframes spine-in {
    from { opacity: 0; transform: translateY(46px); }
    to { opacity: 1; transform: none; }
}

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

    .hero h1,
    .hero-head p,
    .spine { animation: none; }

    .group,
    .spine,
    .spine-art,
    .spine-more,
    .spine-cover img { transition: none; }
}
