/* ============================================================
   Daniel Tan — site styles
   Warm, personal, editorial. One source of truth for every page.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,400&family=Inter:wght@400;500;600&display=swap');

:root {
    --cream: #f6f1e7;
    --cream-deep: #efe7d7;
    --ink: #2b2724;
    --ink-soft: #5a534b;
    --red: #b22222;
    --red-deep: #8f1a1a;
    --brown: #5a3e2b;
    --line: rgba(90, 62, 43, 0.18);
    --sidebar: 300px;
    --contentw: 660px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.06rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(900px 500px at 85% -5%, rgba(178, 34, 34, 0.06), transparent 60%),
        radial-gradient(700px 500px at -5% 30%, rgba(90, 62, 43, 0.05), transparent 60%);
    pointer-events: none;
    z-index: 0;
}

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-deep); }

p { margin: 0 0 1.1em; }
.muted { color: var(--ink-soft); }

h2 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 500;
    font-size: clamp(1.6rem, 3.6vw, 2.1rem);
    line-height: 1.15;
    letter-spacing: -0.015em;
    margin: 0 0 20px;
}

.section-label {
    font-family: 'Fraunces', serif;
    font-size: 0.95rem;
    font-style: italic;
    color: var(--red);
    margin: 0 0 16px;
}

/* ============================================================
   HOME — sidebar + content shell
   ============================================================ */
.shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, var(--contentw));
    gap: 64px;
    max-width: calc(var(--sidebar) + var(--contentw) + 64px + 56px);
    margin: 0 auto;
    padding: 0 28px;
}

aside.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 0;
}

.portrait {
    width: 172px;
    height: 172px;
    border-radius: 26px;
    object-fit: cover;
    border: 1px solid var(--line);
    box-shadow: 0 14px 34px rgba(90, 62, 43, 0.18);
    margin-bottom: 26px;
}

.sidebar .name {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 500;
    font-size: 2rem;
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
}

.sidebar .role { font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 4px; }

.sidebar .loc {
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 26px;
}

.loc .dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--red);
    animation: pulse 2.6s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(178,34,34,0.45); }
    70% { box-shadow: 0 0 0 9px rgba(178,34,34,0); }
    100% { box-shadow: 0 0 0 0 rgba(178,34,34,0); }
}

.navlinks { display: flex; flex-direction: column; gap: 2px; margin-bottom: 26px; }
.navlinks a {
    font-size: 0.92rem;
    color: var(--ink-soft);
    padding: 4px 0 4px 12px;
    border-left: 2px solid transparent;
    transition: all 0.16s ease;
}
.navlinks a:hover { color: var(--red); border-color: var(--red); transform: translateX(2px); }

.socials { display: flex; flex-wrap: wrap; gap: 8px; }
.socials a {
    font-size: 0.82rem;
    padding: 6px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    background: rgba(255,255,255,0.4);
    transition: all 0.18s ease;
}
.socials a:hover { border-color: var(--red); color: var(--red); transform: translateY(-2px); background: #fff; }

main { padding: 12vh 0 0; }

section { padding: 5.5vh 0; }
section:first-child { padding-top: 0; }

.hero h1 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 500;
    font-size: clamp(2.4rem, 5.5vw, 3.7rem);
    line-height: 1.06;
    letter-spacing: -0.02em;
    margin: 0 0 22px;
}
.hero h1 .accent { color: var(--red); font-style: italic; }

.hero .lede {
    font-size: clamp(1.1rem, 2.2vw, 1.28rem);
    color: var(--ink-soft);
    max-width: 40ch;
    margin: 0;
}

.about .big {
    font-family: 'Fraunces', serif;
    font-size: clamp(1.3rem, 3vw, 1.6rem);
    line-height: 1.45;
    font-weight: 400;
}
.about p:not(.big):not(.section-label) { font-size: 1.08rem; }

/* papers */
.paper {
    display: grid;
    grid-template-columns: 84px 1fr;
    gap: 22px;
    padding: 24px 0;
    border-top: 1px solid var(--line);
    align-items: start;
    transition: transform 0.2s ease;
}
.paper:hover { transform: translateX(4px); }
.paper img {
    width: 84px; height: 84px;
    object-fit: cover; border-radius: 10px;
    background: var(--cream-deep); border: 1px solid var(--line);
}
.paper .hook {
    font-family: 'Fraunces', serif;
    font-size: 1.22rem; line-height: 1.3;
    color: var(--ink); display: block; margin-bottom: 6px;
}
.paper:hover .hook { color: var(--red); }
.paper .title { font-size: 0.9rem; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.paper .venue {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em;
    color: var(--red); font-weight: 600;
}

/* writing / link rows */
.stack a.row {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 20px; padding: 16px 0; border-top: 1px solid var(--line); color: var(--ink);
}
.stack a.row:hover { color: var(--red); }
.stack a.row .arr { color: var(--ink-soft); transition: transform 0.18s ease; }
.stack a.row:hover .arr { transform: translate(3px,-3px); color: var(--red); }

/* chips */
.into-grid { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 4px; }
.chip {
    font-size: 0.88rem; padding: 6px 13px; border-radius: 999px;
    background: var(--cream-deep); border: 1px solid var(--line); color: var(--brown);
}

/* now card */
.now-card {
    background: rgba(255,255,255,0.5);
    border: 1px solid var(--line);
    border-left: 3px solid var(--red);
    border-radius: 14px; padding: 24px 26px;
}
.now-card .stamp { font-size: 0.8rem; color: var(--ink-soft); margin-bottom: 8px; }

/* contact */
.contact { padding: 8vh 0; }
.contact h2 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); }
.contact .email {
    font-family: 'Fraunces', serif;
    font-size: clamp(1.25rem, 3vw, 1.7rem);
    color: var(--red);
}

footer.home { font-size: 0.8rem; color: var(--ink-soft); padding: 2vh 0 6vh; }

/* ============================================================
   SUBPAGES — centered article layout
   ============================================================ */
.page {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 0;
    margin-bottom: 4vh;
    border-bottom: 1px solid var(--line);
}
.topbar .wordmark {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    font-size: 1.15rem;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.topbar .wordmark:hover { color: var(--red); }
.backlink { font-size: 0.92rem; color: var(--ink-soft); }
.backlink:hover { color: var(--red); }
.backlink .arr { transition: transform 0.18s ease; display: inline-block; }
.backlink:hover .arr { transform: translateX(-3px); }

.pagehead { margin: 2vh 0 5vh; }
.pagehead .eyebrow {
    font-family: 'Fraunces', serif;
    font-style: italic;
    color: var(--red);
    font-size: 0.95rem;
    margin: 0 0 12px;
}
.pagehead h1 {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.08;
    letter-spacing: -0.02em;
    margin: 0;
}
.pagehead .stamp { font-size: 0.85rem; color: var(--ink-soft); margin-top: 12px; }

.prose { padding-bottom: 8vh; }
.prose p { font-size: 1.08rem; }
.prose h2 { margin-top: 2.2em; }
.prose h3 {
    font-family: 'Fraunces', serif;
    font-weight: 500;
    font-size: 1.25rem;
    margin: 1.8em 0 0.5em;
}
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: 0.4em; }

/* poem / verse block */
.verse {
    margin: 4vh auto;
    max-width: 460px;
    font-family: 'Fraunces', serif;
    font-style: italic;
    color: var(--brown);
    line-height: 2;
    font-size: 1.15rem;
}
.verse p { margin-bottom: 1.8em; }
.verse.centered { text-align: center; }

.figure { margin: 4vh 0; }
.figure img {
    max-width: 100%; height: auto;
    border-radius: 12px;
    border: 1px solid var(--line);
    box-shadow: 0 12px 30px rgba(90, 62, 43, 0.14);
}

/* ============================================================
   Book flip cards (bookshelf)
   ============================================================ */
.book-card {
    perspective: 1200px;
    margin: 22px 0;
    cursor: pointer;
    height: 200px;
}
.book-card-inner {
    position: relative;
    width: 100%; height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}
.book-card.flipped .book-card-inner { transform: rotateY(180deg); }
.book-card-front, .book-card-back {
    position: absolute; inset: 0;
    backface-visibility: hidden;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.55);
    box-shadow: 0 8px 22px rgba(90, 62, 43, 0.1);
}
.book-card-front { display: flex; align-items: center; gap: 22px; padding: 22px; }
.book-cover-image img {
    width: 110px; height: 160px; object-fit: cover;
    border-radius: 8px; box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}
.book-info .book-title {
    font-family: 'Fraunces', serif; font-size: 1.35rem; line-height: 1.2; color: var(--ink);
}
.book-info .book-author { color: var(--ink-soft); margin: 4px 0 14px; }
.flip-hint { font-size: 0.82rem; font-style: italic; color: var(--red); }
.book-card-back {
    transform: rotateY(180deg);
    display: flex; align-items: center;
    padding: 26px 30px;
    background: var(--cream-deep);
    border-left: 3px solid var(--red);
}
.book-card-back p { margin: 0; font-size: 1.02rem; line-height: 1.6; }

/* ============================================================
   Collapsible (dating outtakes)
   ============================================================ */
.collapsible-section { margin: 4vh 0; }
.collapsible-header {
    background: rgba(255,255,255,0.5);
    border: 1px solid var(--line);
    border-left: 3px solid var(--red);
    border-radius: 12px;
    padding: 22px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.collapsible-header:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(90,62,43,0.12); }
.collapsible-header h3 { margin: 0; font-family: 'Fraunces', serif; font-weight: 500; font-size: 1.25rem; color: var(--ink); }
.collapsible-hint { font-size: 0.82rem; font-style: italic; color: var(--ink-soft); margin-top: 6px; }
.collapsible-content { max-height: 0; overflow: hidden; transition: max-height 0.5s ease-out; }
.collapsible-content.active { max-height: 2000px; }
.collapsible-content-inner {
    background: var(--cream-deep);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 6px 26px 22px;
    margin-top: 12px;
}

/* ============================================================
   Reveal + responsive
   ============================================================ */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
    .loc .dot { animation: none; }
    html { scroll-behavior: auto; }
}

@media (max-width: 880px) {
    .shell { grid-template-columns: 1fr; gap: 0; }
    aside.sidebar {
        position: static; height: auto;
        justify-content: flex-start;
        padding: 9vh 0 2vh;
    }
    .navlinks { display: none; }
    main { padding: 4vh 0 0; }
    section:first-child { padding-top: 2vh; }
}

@media (max-width: 540px) {
    .book-card { height: auto; }
    .book-card-inner { transform: none !important; }
    .book-card-front, .book-card-back {
        position: static; backface-visibility: visible; transform: none;
    }
    .book-card-back { margin-top: 12px; }
    .flip-hint { display: none; }
}
