/* ==========================================================================
   joeste.ch

   The background light simulation — sections 3 and the sunrise/sunset
   keyframes — is adapted, with thanks, from "sunlit" by Jacky Zhao:
   https://github.com/jackyzha0/sunlit
   assets/img/leaves.png comes from that project as well.

   Everything above it is a reading-first type system: the room is
   atmosphere, the text is the point.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */

:root {
    /* The hours of the day, from sunlit. These never change; the theme picks. */
    --day: #fffdfa;
    --evening: #fccc83;
    --dusk: #db7a2a;
    --night: #0f131c;
    --dawn: #16132b;
    --morning: #9fb3bf;

    --surface: var(--day);
    --ink: #23201c;
    --ink-soft: #6d645a;
    --ink-faint: #948a7e;
    --rule: rgba(35, 32, 28, 0.13);
    --rule-strong: rgba(35, 32, 28, 0.28);
    --accent: #a94e14;
    --accent-soft: rgba(169, 78, 20, 0.1);
    --panel: rgba(255, 253, 250, 0.5);
    --code-bg: rgba(35, 32, 28, 0.06);

    --shadow: #1a1917;
    --bounce-light: #f5d7a6;
    --overlay: 0.07;

    --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino,
             Georgia, ui-serif, serif;
    --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
            Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --measure: 34rem;
    --wide: 52rem;
    --timing-fn: cubic-bezier(0.455, 0.19, 0, 0.985);
}

:root.dark {
    --surface: var(--night);
    --ink: #e7e3db;
    --ink-soft: #9aa2ac;
    --ink-faint: #6f7883;
    --rule: rgba(231, 227, 219, 0.14);
    --rule-strong: rgba(231, 227, 219, 0.3);
    --accent: #fccc83;
    --accent-soft: rgba(252, 204, 131, 0.12);
    --panel: rgba(22, 26, 36, 0.45);
    --code-bg: rgba(231, 227, 219, 0.08);

    --shadow: #030307;
    --bounce-light: #1b293f;
    --overlay: 0.3;

}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */

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

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

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--surface);
    color: var(--ink);
    font-family: var(--serif);
    font-size: 1.125rem;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;

    animation-duration: 0s;
    animation-fill-mode: forwards;
    animation-timing-function: linear;
}

/* The sunrise/sunset wash only plays once the reader has asked for it. */
:root.animation-ready body { animation-duration: 1s; animation-name: sunrise; }
:root.animation-ready.dark body { animation-duration: 1.7s; animation-name: sunset; }

@keyframes sunrise {
    0%   { background-color: var(--night); }
    10%  { background-color: var(--dawn); }
    35%  { background-color: var(--morning); }
    100% { background-color: var(--day); }
}

@keyframes sunset {
    0%   { background-color: var(--day); }
    30%  { background-color: var(--evening); }
    60%  { background-color: var(--dusk); }
    90%  { background-color: var(--dawn); }
    100% { background-color: var(--night); }
}

::selection { background: var(--accent-soft); }

a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10;
    padding: 0.6rem 1rem;
    background: var(--surface);
    border: 1px solid var(--rule-strong);
    font-family: var(--sans);
    font-size: 0.9rem;
}
.skip-link:focus { left: 1rem; top: 1rem; }

.svg-defs { position: absolute; width: 0; height: 0; }

/* --------------------------------------------------------------------------
   3. The room (sunlit)
   -------------------------------------------------------------------------- */

#dappled-light {
    pointer-events: none;
    position: fixed;
    inset: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    z-index: 0;
}

#progressive-blur { position: absolute; inset: 0; height: 100%; width: 100%; }

#progressive-blur > div {
    position: absolute;
    inset: 0;
    height: 100%;
    width: 100%;
    backdrop-filter: blur(var(--blur-amount));
    mask-image: linear-gradient(252deg, transparent, transparent var(--stop1),
                                black var(--stop2), black);
}
#progressive-blur > div:nth-child(1) { --blur-amount: 6px;  --stop1: 0%;  --stop2: 0%; }
#progressive-blur > div:nth-child(2) { --blur-amount: 12px; --stop1: 40%; --stop2: 80%; }
#progressive-blur > div:nth-child(3) { --blur-amount: 48px; --stop1: 40%; --stop2: 70%; }
#progressive-blur > div:nth-child(4) { --blur-amount: 96px; --stop1: 70%; --stop2: 80%; }

#glow {
    position: absolute;
    inset: 0;
    height: 100%;
    width: 100%;
    opacity: 0.5;
    background: linear-gradient(309deg, var(--bounce-light), var(--bounce-light) 20%, transparent);
    transition: background 1s var(--timing-fn);
}

#glow-bounce {
    position: absolute;
    bottom: 0;
    height: 100%;
    width: 100%;
    opacity: 0.5;
    background: linear-gradient(355deg, var(--bounce-light) 0%, transparent 30%, transparent 100%);
    transition: background 1s var(--timing-fn);
}

.perspective {
    position: absolute;
    top: -30vh;
    right: 0;
    width: 80vw;
    height: 130vh;
    opacity: var(--overlay);
    background-blend-mode: darken;
    transform-origin: top right;
    transform-style: preserve-3d;
    transform: matrix3d(0.75, -0.0625, 0, 0.0008,
                        0, 1, 0, 0,
                        0, 0, 1, 0,
                        0, 0, 0, 1);
    transition: transform 1.7s var(--timing-fn), opacity 4s ease;
}

:root.dark .perspective {
    transform: matrix3d(0.8333, 0.0833, 0, 0.0003,
                        0, 1, 0, 0,
                        0, 0, 1, 0,
                        0, 0, 0, 1);
}

/* Long-form pages dim the room so the shadows never compete with the text. */
body.page-essay .perspective { opacity: calc(var(--overlay) * 0.6); }

#leaves {
    position: absolute;
    bottom: -20px;
    right: -700px;
    width: 1600px;
    height: 1400px;
    background-image: url("/assets/img/leaves.png");
    background-size: cover;
    background-repeat: no-repeat;
    filter: url(#wind);
    animation: billow 8s ease-in-out infinite;
}

#blinds { position: relative; width: 100%; }
#blinds .shutter, #blinds .bar { background-color: var(--shadow); }

#blinds > .shutters {
    display: flex;
    flex-direction: column;
    align-items: end;
    gap: 60px;
    transition: gap 1s var(--timing-fn);
}
:root.dark #blinds > .shutters { gap: 20px; }

#blinds > .vertical {
    position: absolute;
    top: 0;
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: space-around;
}
.vertical > .bar { width: 5px; height: 100%; }

.shutter { width: 100%; height: 40px; transition: height 1s var(--timing-fn); }
:root.dark .shutter { height: 80px; }

@keyframes billow {
    0%   { transform: perspective(400px) rotateX(0deg) rotateY(0deg) scale(1); }
    25%  { transform: perspective(400px) rotateX(1deg) rotateY(2deg) scale(1.02); }
    50%  { transform: perspective(400px) rotateX(-4deg) rotateY(-2deg) scale(0.97); }
    75%  { transform: perspective(400px) rotateX(1deg) rotateY(-1deg) scale(1.04); }
    100% { transform: perspective(400px) rotateX(0deg) rotateY(0deg) scale(1); }
}

/* --------------------------------------------------------------------------
   4. Shell
   -------------------------------------------------------------------------- */

.shell {
    position: relative;
    z-index: 1;
    isolation: isolate;
    max-width: var(--wide);
    margin: 0 auto;
    padding: 0 1.5rem 5rem;
}

.site-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 2rem 0 3.5rem;
}

.wordmark {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--ink);
    text-decoration: none;
}
.wordmark:hover { color: var(--accent); }

.site-nav {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-family: var(--sans);
    font-size: 0.875rem;
    letter-spacing: 0.02em;
}
.site-nav a {
    color: var(--ink-soft);
    text-decoration: none;
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
}
.site-nav a:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* --------------------------------------------------------------------------
   5. The blinds toggle
   A miniature of the window behind it: slats spread apart for daylight,
   and swing shut for night.
   -------------------------------------------------------------------------- */

.theme-toggle {
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    padding: 0;
    /* No frame of its own — the window below is the only box, otherwise the
       nested rounded squares read as a generic icon button. */
    border: 0;
    border-radius: 0.4rem;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease;
}
.theme-toggle:hover { color: var(--ink); background: var(--accent-soft); }

/* Sun for day, moon for night. The two icons sit on top of each other and
   swap with a short rotation. */
.theme-toggle svg {
    grid-area: 1 / 1;
    width: 1.15rem;
    height: 1.15rem;
    fill: currentColor;
    transition: opacity 0.35s ease, transform 0.45s var(--timing-fn);
}

/* The icon shows what you get if you click it: the moon takes you to night,
   the sun brings the day back. */
.icon-sun { opacity: 0; transform: rotate(-60deg) scale(0.6); }
.icon-moon { opacity: 1; transform: none; }
:root.dark .icon-sun { opacity: 1; transform: none; }
:root.dark .icon-moon { opacity: 0; transform: rotate(60deg) scale(0.6); }

/* --------------------------------------------------------------------------
   6. Prose
   -------------------------------------------------------------------------- */

main { min-height: 40vh; }

h1, h2, h3, h4 {
    font-family: var(--serif);
    line-height: 1.2;
    letter-spacing: -0.012em;
    font-weight: 600;
    margin: 2.5em 0 0.6em;
    text-wrap: balance;
}
h1 { font-size: clamp(1.95rem, 1.5rem + 2vw, 2.65rem); margin-top: 0; letter-spacing: -0.02em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.18rem; }
h4 { font-size: 1rem; letter-spacing: 0.02em; text-transform: uppercase; font-family: var(--sans); color: var(--ink-soft); }

p, ul, ol, blockquote, pre, .table-wrap, figure { margin: 0 0 1.35em; }

main > p, main > ul, main > ol, main > blockquote, main > h2, main > h3,
main > h4, main > pre, main > figure, main > .table-wrap, main > hr {
    max-width: var(--measure);
}

main > ul, main > ol { padding-left: 1.2em; }
li { margin-bottom: 0.4em; }
li > ul, li > ol { margin: 0.4em 0; }

blockquote {
    padding-left: 1.2em;
    border-left: 2px solid var(--rule-strong);
    color: var(--ink-soft);
    font-style: italic;
}
blockquote p:last-child { margin-bottom: 0; }

hr {
    border: 0;
    height: 1px;
    background: var(--rule);
    margin: 3em 0;
}

code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
}

pre {
    max-width: var(--wide);
    overflow-x: auto;
    padding: 1rem 1.15rem;
    background: var(--code-bg);
    border: 1px solid var(--rule);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.55;
}
pre code { background: none; padding: 0; font-size: inherit; }

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

main > p > img, figure img {
    margin: 2em auto;
    border-radius: 0.4rem;
    border: 1px solid var(--rule);
}

figure { max-width: var(--wide); }
figcaption {
    font-family: var(--sans);
    font-size: 0.82rem;
    color: var(--ink-faint);
    text-align: center;
    margin-top: 0.6em;
}

.table-wrap { overflow-x: auto; max-width: var(--wide); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { padding: 0.55em 0.8em; border-bottom: 1px solid var(--rule); text-align: left; }
th { font-family: var(--sans); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }

/* --------------------------------------------------------------------------
   7. Post furniture
   -------------------------------------------------------------------------- */

.post-header { margin-bottom: 3rem; max-width: var(--measure); }
.post-header h1 { margin: 0.5rem 0 0.7rem; }

.post-meta, .card-meta {
    font-family: var(--sans);
    font-size: 0.83rem;
    color: var(--ink-faint);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.6; }

.tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0;
    margin: 0.9rem 0 0;
    font-family: var(--sans);
    font-size: 0.76rem;
    color: var(--ink-faint);
}
.tags li {
    margin: 0;
    padding: 0.1em 0.55em;
    border: 1px solid var(--rule);
    border-radius: 999px;
}

/* --------------------------------------------------------------------------
   8. Listings
   -------------------------------------------------------------------------- */

.cards { list-style: none; padding: 0; margin: 0; max-width: var(--wide); }

.card {
    /* Two lines per row now that summaries are gone; the old padding was
       balanced against a third. */
    padding: 1.05rem 0;
    border-top: 1px solid var(--rule);
    margin: 0;
}
.card:last-child { border-bottom: 1px solid var(--rule); }
.card h2 { margin: 0.28rem 0 0; font-size: 1.22rem; letter-spacing: -0.01em; }
.card h2 a { color: var(--ink); text-decoration: none; }
.card h2 a:hover { color: var(--accent); text-decoration: underline; }

/* Writing published elsewhere. Same shape as a local post, but the source is
   named and the title carries an arrow so it is obvious you are leaving. */
.card-source {
    color: var(--ink-soft);
}
.card-external h2 a::after {
    content: "↗";
    display: inline-block;
    margin-left: 0.3em;
    font-size: 0.78em;
    color: var(--ink-faint);
    transition: transform 0.2s var(--timing-fn), color 0.2s ease;
}
.card-external h2 a:hover::after {
    color: var(--accent);
    transform: translate(1px, -1px);
}

.empty { color: var(--ink-faint); font-style: italic; }

/* The current anthology, given a cover and a little room. */
.feature {
    display: flex;
    align-items: center;
    gap: 2rem;
    max-width: var(--wide);
    margin: 0 0 2.5rem;
}

.feature-cover {
    flex: none;
    display: block;
    width: 11rem;
    border-radius: 0.3rem;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--rule), 0 14px 34px -20px var(--shadow);
    transition: transform 0.3s var(--timing-fn), box-shadow 0.3s ease;
}
.feature-cover:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px var(--rule-strong), 0 20px 40px -20px var(--shadow);
}
.feature-cover img { width: 100%; height: auto; }

.feature-text { min-width: 0; }
.feature-text h2 { margin: 0 0 0.5rem; font-size: 1.5rem; }
.feature-text p { margin: 0 0 0.6rem; max-width: var(--measure); }
.feature-text p:last-child { margin-bottom: 0; font-family: var(--sans); font-size: 0.9rem; }

/* A single destination, presented as a door rather than a sentence. */
.link-card {
    position: relative;
    display: block;
    max-width: var(--wide);
    margin: 0 0 1rem;
    padding: 1.4rem 3.25rem 1.4rem 1.5rem;
    border: 1px solid var(--rule);
    border-radius: 0.6rem;
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
    transition: background 0.25s ease, border-color 0.25s ease;
}
.link-card:hover { background: var(--accent-soft); border-color: var(--accent); }
.link-card strong { display: block; font-size: 1.15rem; font-weight: 600; }
.link-card span {
    display: block;
    margin-top: 0.2rem;
    font-family: var(--sans);
    font-size: 0.87rem;
    color: var(--ink-soft);
}
.link-card::after {
    content: "→";
    position: absolute;
    right: 1.4rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    transition: transform 0.25s var(--timing-fn);
}
.link-card:hover::after { transform: translateY(-50%) translateX(3px); }

/* --------------------------------------------------------------------------
   9. Home
   -------------------------------------------------------------------------- */

.hero {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    max-width: var(--wide);
    margin: 0 0 4rem;
}

.hero-photo {
    flex: none;
    width: 11rem;
    height: 11rem;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 1px var(--rule), 0 12px 32px -18px var(--shadow);
}

.hero-text { min-width: 0; }
.hero-text h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(2rem, 1.6rem + 1.6vw, 2.7rem);
}
.hero-text p {
    margin: 0 0 0.6rem;
    max-width: var(--measure);
    font-size: 1.16rem;
    color: var(--ink-soft);
}
.hero-contact {
    font-family: var(--sans);
    font-size: 0.9rem;
}

.doors {
    list-style: none;
    padding: 0;
    margin: 0 0 4rem;
    max-width: var(--wide);
    display: grid;
    /* One column per door, so none is ever stranded on a row of its own. */
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
    border-radius: 0.6rem;
    overflow: hidden;
}
.doors li { margin: 0; }
.doors a {
    display: block;
    height: 100%;
    padding: 1.5rem 1.4rem;
    background: var(--panel);
    text-decoration: none;
    color: var(--ink);
    transition: background 0.25s ease;
}
.doors a:hover { background: var(--accent-soft); }
.doors strong {
    display: block;
    font-size: 1.08rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.doors span {
    display: block;
    font-family: var(--sans);
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   10. Footer
   -------------------------------------------------------------------------- */

.site-footer {
    margin-top: 6rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--rule);
    font-family: var(--sans);
    font-size: 0.83rem;
    color: var(--ink-faint);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-bottom: 0.9rem; }
.footer-links a { color: var(--ink-soft); text-decoration: none; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }
.colophon { margin: 0; }

/* --------------------------------------------------------------------------
   11. Responsive, motion, print
   -------------------------------------------------------------------------- */

@media (max-width: 46rem) {
    body { font-size: 1.06rem; }
    .shell { padding: 0 1.15rem 3.5rem; }
    .site-header { flex-wrap: wrap; gap: 0.85rem; padding: 1.5rem 0 2.5rem; }
    .site-nav { order: 3; width: 100%; margin-left: 0; gap: 1rem; }
    .theme-toggle { margin-left: auto; }
    .doors { grid-template-columns: 1fr; }
    /* The window is drawn for wide screens; on a phone it just eats contrast. */
    .perspective { opacity: calc(var(--overlay) * 0.5); }

    .hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        margin-bottom: 3rem;
    }
    .hero-photo { width: 7.5rem; height: 7.5rem; }

    .feature {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.4rem;
    }
    .feature-cover { width: 9rem; }
}

@media (prefers-reduced-motion: reduce) {
    #leaves { animation: none; filter: none; }
    :root.animation-ready body { animation: none; }
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media print {
    #dappled-light, .site-nav, .theme-toggle, .site-footer, .skip-link { display: none; }
    body { background: #fff; color: #000; font-size: 11pt; }
    .shell { max-width: none; padding: 0; }
    a { text-decoration: underline; }
    main > * { max-width: none; }
}
