:root {
    /* Hanji, the warm mulberry paper of a Korean screen door. */
    --ground: #f4eee3;
    --ink: #2b2420;
    --ink-soft: #5a4f47;
    --ink-faint: #8a7d72;
    --accent: #c8381e; /* gochujang, from the kimchi on the icon */
    --rim: #2350a8; /* the blue band on the icon's plate */
    --rule: rgba(43, 36, 32, 0.16);
    --shade: 40, 26, 16;

    --font-display: "Noto Serif KR", "Apple SD Gothic Neo", serif;
    --font-serif: "Source Serif 4", "Noto Serif KR", "Iowan Old Style", Georgia, serif;
    --font-mono: "IBM Plex Mono", "Noto Serif KR", ui-monospace, Menlo, monospace;
    --font-body: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;

    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Lacquered wood after dark. */
        --ground: #1c1815;
        --ink: #f4ece0;
        --ink-soft: #c7bbad;
        --ink-faint: #8f8478;
        --accent: #ff7a4d;
        --rim: #8fb0ff;
        --rule: rgba(244, 236, 224, 0.16);
        --shade: 0, 0, 0;
    }
}

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

html,
body {
    height: 100%;
}

body {
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

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

/* ---------- Single-screen home page ---------- */

.home {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: grid;
    grid-template-rows: 1fr auto;
}

.stage {
    display: grid;
    grid-template-columns: minmax(300px, 0.9fr) 1.1fr;
    align-items: center;
    gap: 2rem;
    padding: 2rem clamp(1.5rem, 5vw, 5rem) 0;
    padding-left: max(clamp(1.5rem, 5vw, 5rem), env(safe-area-inset-left));
    padding-right: max(clamp(1.5rem, 5vw, 5rem), env(safe-area-inset-right));
    min-height: 0;
}

.intro {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 31rem;
}

.app-icon {
    width: 72px;
    height: 72px;
    border-radius: 22.5%;
    box-shadow:
        0 1px 1px rgba(var(--shade), 0.14),
        0 3px 6px rgba(var(--shade), 0.16),
        0 10px 20px rgba(var(--shade), 0.18),
        0 24px 44px rgba(var(--shade), 0.22);
    margin-bottom: 1.75rem;
}

/* ---------- Name and copy ---------- */

.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-bottom: 0.6rem;
}

.app-name {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(3.5rem, 7vw, 6rem);
    line-height: 1;
    letter-spacing: -0.02em;
    margin-bottom: 0.7rem;
}

.gloss {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--ink-faint);
    margin-bottom: 1.5rem;
}

.description {
    font-family: var(--font-serif);
    font-size: clamp(1.1rem, 1.45vw, 1.3rem);
    line-height: 1.55;
    color: var(--ink-soft);
    margin-bottom: 0.9rem;
    text-wrap: pretty;
}

.description [lang="ko"] {
    font-size: 0.94em;
}

.aside {
    font-style: italic;
    color: var(--ink-faint);
    margin-bottom: 1.6rem;
}

/* 오방색, the five colors a good table balances, laid out like the dots on the app's receipt. */
.obangsaek {
    list-style: none;
    display: flex;
    gap: 0.85rem;
    margin-bottom: 1.9rem;
}

.obangsaek li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-display);
    font-size: 0.75rem;
    color: var(--ink-faint);
}

.obangsaek li::before {
    content: "";
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--dot);
    box-shadow: inset 0 0 0 1px var(--rule), 0 1px 2px rgba(var(--shade), 0.15);
}

.app-store-badge {
    display: inline-block;
    line-height: 0;
    transition: transform 0.2s ease;
}

.app-store-badge:hover {
    transform: translateY(-1px) rotate(-1deg);
}

.app-store-badge img {
    height: 54px;
    width: auto;
}

.compat {
    margin-top: 1rem;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.95rem;
    color: var(--ink-faint);
}

.compat [lang="ko"] {
    font-style: normal;
    font-size: 0.9em;
    margin-left: 0.25em;
}

/* ---------- The rendered iPhone ---------- */

.scene {
    /* --w is the phone's width; every other measurement derives from it. */
    --w: min(24vw, 35vh, 360px);
    --t: calc(var(--w) * 0.115); /* thickness */
    --b: calc(var(--w) * 0.034); /* bezel, glass edge to screen */
    --lip: calc(var(--w) * 0.006); /* metal showing around the glass */
    /* Height over width of the recording (1206 x 2622). The phone is sized so the screen,
       inside the bezel, has exactly this shape. */
    --media-aspect: 2.17413;
    --h: calc((var(--w) - var(--b) * 2) * var(--media-aspect) + var(--b) * 2);
    --sr: calc((var(--w) - var(--b) * 2) * 0.145); /* screen corner radius */
    --r: calc(var(--sr) + var(--b)); /* outer corner radius, concentric with the screen */

    position: relative;
    height: 100%;
    min-height: 0;
}

.view {
    position: relative;
    height: 100%;
    display: grid;
    place-items: center;
    perspective: calc(var(--w) * 6);
}

.stand,
.phone {
    position: relative;
    width: var(--w);
    height: var(--h);
    transform-style: preserve-3d;
}

/* Swings in from the side as the page opens. The phone itself is turned by the script,
   so the entrance lives on its own wrapper. */
.stand {
    animation: swing-in 1.5s cubic-bezier(0.25, 0.7, 0.2, 1) 0.15s both;
}

@keyframes swing-in {
    from { transform: translateY(5%) rotateY(55deg); }
}

.phone {
    /* The script turns this toward the pointer. */
    transform: rotateX(5deg) rotateY(-20deg);
}

.face {
    position: absolute;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.front {
    inset: var(--lip);
    border-radius: calc(var(--r) - var(--lip));
    background: #050506;
}

/* The frame: rounded slices stacked through the thickness, so the edge follows the corners.
   Anodized orange aluminum, lit from the upper left. The deepest slice closes the back. */
.layer {
    inset: 0;
    border-radius: var(--r);
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
    background: linear-gradient(170deg, #f6a46b 0%, #dc6d31 30%, #b9521f 70%, #8a3814 100%);
}

/* Side button and Camera Control on the right edge, the edge turned toward the viewer. */
.key {
    left: calc(100% + 0.5px);
    width: calc(var(--t) * 0.42);
    transform-origin: 0 50%;
    transform: translateZ(calc(var(--t) * -0.29)) rotateY(90deg);
    border-radius: 999px;
    background: linear-gradient(to bottom, #e98a50, #b4501f);
    box-shadow: inset 0 0 0 1px rgba(80, 30, 8, 0.35);
}

.side-button {
    top: 25%;
    height: 11%;
}

.camera-control {
    top: 53%;
    height: 7%;
    background: linear-gradient(to bottom, #c9a48c, #8f6a55);
}

.screen-canvas {
    inset: var(--b);
    width: calc(100% - var(--b) * 2);
    height: calc(100% - var(--b) * 2);
    border-radius: var(--sr);
    transform: translateZ(0.5px);
    background: #000;
}

/* A soft reflection floating just above the glass. */
.glare {
    inset: var(--b);
    border-radius: var(--sr);
    transform: translateZ(1px);
    pointer-events: none;
    background: linear-gradient(118deg, rgba(255, 255, 255, 0.13) 0%, rgba(255, 255, 255, 0.03) 34%, transparent 34.2%);
}

/* The phone floats; its shadow pools on the page below it. */
.ground-shadow {
    position: absolute;
    left: 50%;
    top: calc(50% + var(--h) * 0.5 + var(--w) * 0.05);
    width: calc(var(--w) * 1.25);
    height: calc(var(--w) * 0.16);
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(var(--shade), 0.32), rgba(var(--shade), 0.12) 60%, transparent);
    filter: blur(calc(var(--w) * 0.03));
    pointer-events: none;
}

/* ---------- Footer ---------- */

.site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding: 1rem clamp(1.5rem, 5vw, 5rem) 1.25rem;
    padding-left: max(clamp(1.5rem, 5vw, 5rem), env(safe-area-inset-left));
    padding-right: max(clamp(1.5rem, 5vw, 5rem), env(safe-area-inset-right));
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
    font-size: 0.8125rem;
    color: var(--ink-faint);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
}

.site-footer a {
    text-decoration: none;
    color: var(--ink-soft);
}

.site-footer a:hover {
    color: var(--ink);
}

.thanks {
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* ---------- Narrow and portrait screens ---------- */

@media (max-width: 820px), (max-aspect-ratio: 1/1) {
    /* The page is one screen tall, and only grows (and scrolls) when the copy leaves too
       little room under it for the phone. */
    .home {
        height: auto;
        min-height: 100vh;
        min-height: 100svh;
        overflow: visible;
    }

    .stage {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(22rem, 1fr);
        align-items: start;
        gap: 0;
        padding-top: clamp(1.25rem, 4vh, 3rem);
        text-align: center;
    }

    .intro {
        align-items: center;
        margin: 0 auto;
    }

    .app-icon {
        width: 52px;
        height: 52px;
        margin-bottom: 0.9rem;
    }

    .app-name {
        font-size: clamp(3rem, 14vw, 4.25rem);
        margin-bottom: 0.5rem;
    }

    .gloss {
        margin-bottom: 1rem;
    }

    .description {
        font-size: 1.02rem;
        line-height: 1.5;
        margin-bottom: 0.75rem;
    }

    .aside {
        margin-bottom: 1.25rem;
    }

    .obangsaek {
        gap: 0.7rem;
        margin-bottom: 1.2rem;
    }

    .obangsaek li::before {
        width: 1.05rem;
        height: 1.05rem;
    }

    .app-store-badge img {
        height: 46px;
    }

    .compat {
        display: none;
    }

    /* The phone fills whatever room is left under the copy. */
    .scene {
        container-type: size;
        padding: 0.75rem 0 1.5rem;
        --w: min(46cqw, 41cqh, 300px);
    }

    .site-footer {
        flex-direction: column;
        justify-content: center;
        text-align: center;
    }
}

/* Small phones: the copy tightens to keep the phone in view. */
@media (max-width: 420px) {
    .description {
        font-size: 0.98rem;
        line-height: 1.45;
    }

    .aside {
        display: none;
    }
}

@media (max-height: 640px) and (min-width: 821px) {
    .app-icon { display: none; }
    .obangsaek { display: none; }
}

@media (prefers-color-scheme: dark) {
    .ground-shadow {
        background: radial-gradient(closest-side, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.25) 60%, transparent);
    }

    .app-icon {
        box-shadow:
            0 0 0 1px rgba(255, 255, 255, 0.06),
            0 1px 1px rgba(0, 0, 0, 0.3),
            0 3px 6px rgba(0, 0, 0, 0.32),
            0 10px 20px rgba(0, 0, 0, 0.36),
            0 24px 44px rgba(0, 0, 0, 0.42);
    }
}

@media (prefers-reduced-motion: reduce) {
    .stand { animation: none; }
}

/* ---------- Text pages (privacy, support) ---------- */

.page-body {
    background: var(--ground);
    min-height: 100%;
}

.page {
    max-width: 40rem;
    margin: 0 auto;
    padding: 3rem 1.5rem 4rem;
    font-family: var(--font-serif);
    font-size: 1.0625rem;
    line-height: 1.65;
}

.page .back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1.05rem;
    color: var(--ink-soft);
    text-decoration: none;
    margin-bottom: 2.5rem;
}

.page .back-link img {
    width: 30px;
    height: 30px;
    border-radius: 22.5%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16), 0 4px 10px rgba(0, 0, 0, 0.12);
}

.page h1 {
    font-weight: 700;
    font-size: 2.6rem;
    letter-spacing: -0.015em;
    line-height: 1.05;
    margin-bottom: 1.5rem;
}

.page h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 2.25rem 0 0.4rem;
}

.page p,
.page li {
    color: var(--ink-soft);
    margin-bottom: 0.75rem;
}

.page ul {
    padding-left: 1.25rem;
}

.page a {
    color: var(--ink);
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.page .updated {
    margin-top: 2.5rem;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--ink-faint);
}
