/* assets/site.css -- shared styles for the public content pages
   (daily-word, gallery, profiles, drawing permalinks).

   Design language is borrowed from the iOS app, not invented for the web:
   - "Cardstock" background: cool blue paper with subtle grain
     (PaperCoolBlue in AAABackgrounds/LCG.swift), dark purple in dark mode
     (PaperDarkPurple2). Grain here is an inline-SVG noise tile.
   - Content floats on a white "paper card" (PaperCard: 18pt continuous
     corners, hairline stroke, soft shadow).
   - Serif is the content voice (GalleryCellLayout): bold serif words
     overlaid on drawings with a doubled drop shadow, italic serif bylines.
   No gradient text, no gradient buttons. */

:root {
    color-scheme: light dark;
    --accent: #ff5e62;
    --ink: #1c1c1e;
    --serif: ui-serif, "Iowan Old Style", Georgia, "Times New Roman", serif;
    --paper-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.05'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: #e9f1fa;
    background-image: var(--paper-noise), linear-gradient(180deg, #edf5fc 0%, #e6f0fa 100%);
    background-attachment: fixed;
    color: var(--ink);
    line-height: 1.55;
}
a { color: #d94a4f; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

h1, h2, h3 { font-family: var(--serif); letter-spacing: 0; }

/* --- nav: see _inc/site_nav.php (self-contained partial shared with the
   static pages, styles inlined there) --- */

/* --- layout: the app's PaperCard, as a page --- */
.site-main {
    max-width: 1080px;
    margin: 1.4rem auto 2.25rem;
    padding: 1.6rem 1.5rem 2.25rem;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}
@media (max-width: 1120px) {
    .site-main { margin-left: 0.8rem; margin-right: 0.8rem; }
}
@media (max-width: 600px) {
    .site-main { margin: 0.7rem 0.5rem 1.5rem; padding: 1.1rem 0.9rem 1.6rem; border-radius: 14px; }
}
.page-head { margin: 0.25rem 0 1.5rem; }
.page-head h1 {
    font-size: clamp(1.7rem, 4.5vw, 2.4rem);
    font-weight: 700;
    margin: 0 0 0.5rem;
}
.page-head .accent-word { color: var(--accent); }
.page-head p { margin: 0.25rem 0; color: #55555a; max-width: 46rem; }
.breadcrumbs { font-size: 0.85rem; color: #8e8e93; margin: 0 0 0.5rem; }
.breadcrumbs a { color: #8e8e93; }

/* --- drawing grid: ported from the app's GalleryCellLayout --- */
.drawing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.1rem 1rem;
    margin: 1.25rem 0;
}
.drawing-card { margin: 0; }
.drawing-card > a {
    display: block;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.10);
    background: white;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.drawing-card > a:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
}
.drawing-card img { display: block; width: 100%; aspect-ratio: 1/1; background: white; }

/* The word, on the drawing: bold white serif, doubled drop shadow
   (soft wide pass + tight dark pass, like the app). */
.card-overlay-word {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    text-align: center;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
    text-shadow:
        0 0 2px rgba(0, 0, 0, 0.85),
        0 1px 3px rgba(0, 0, 0, 0.70),
        0 2px 10px rgba(0, 0, 0, 0.45);
    padding: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

/* Byline row under the drawing: avatar, italic serif name, reactions. */
.card-byline {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.85rem;
    min-height: 20px;
}
.card-byline .byline-name {
    font-family: var(--serif);
    font-style: italic;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.avatar-20 {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}
.card-reactions { display: flex; gap: 0.55rem; white-space: nowrap; margin-left: auto; }
.card-likes, .card-superlikes { color: var(--accent); font-weight: 600; }

/* Loading spinner: shown in the square while the drawing PNG is still
   rendering server-side; a small script in site_header removes the class
   the moment each image loads. The drawings are opaque white squares, so
   even without JS a loaded image simply covers the spinner. */
.img-loading { position: relative; }
.img-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 28px;
    height: 28px;
    border: 3px solid rgba(0, 0, 0, 0.12);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: hd-spin 0.8s linear infinite;
}
@keyframes hd-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .img-loading::before { animation: none; border-top-color: rgba(0, 0, 0, 0.12); }
}

/* --- word chips / category sections --- */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0 1.5rem; }
.chip {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 999px;
    padding: 0.3rem 0.85rem;
    font-size: 0.9rem;
    color: inherit;
    white-space: nowrap;
}
.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.chip .count { color: #8e8e93; font-size: 0.8rem; margin-left: 0.3rem; }
.section-title { font-size: 1.3rem; font-weight: 700; margin: 2rem 0 0.25rem; }

/* --- single drawing page --- */
.drawing-hero {
    display: grid;
    grid-template-columns: minmax(0, 560px) minmax(240px, 1fr);
    gap: 2rem;
    align-items: start;
    margin: 0.75rem 0 2rem;
}
@media (max-width: 720px) { .drawing-hero { grid-template-columns: 1fr; } }
.drawing-hero .art {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 14px;
    overflow: hidden;
}
.drawing-hero .art img { display: block; width: 100%; aspect-ratio: 1/1; }
.drawing-facts h1 { margin: 0 0 0.75rem; font-size: clamp(1.5rem, 4vw, 2.2rem); }
.drawing-facts h1 .accent-word { color: var(--accent); }
.drawing-facts dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; }
.drawing-facts dt { color: #8e8e93; }
.drawing-facts dd { margin: 0; }

/* --- profile header --- */
.profile-head { display: flex; align-items: center; gap: 1.1rem; margin: 0.5rem 0 1.5rem; }
.profile-head .avatar {
    width: 76px; height: 76px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 700;
    font-family: var(--serif);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}
.profile-head .avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-head h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.1rem); }
.profile-head .stats { color: #55555a; font-size: 0.95rem; }

/* --- archive table --- */
.archive-list { list-style: none; margin: 1rem 0; padding: 0; }
.archive-list li {
    display: flex; align-items: baseline; gap: 0.9rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.archive-list .date { color: #8e8e93; font-variant-numeric: tabular-nums; font-size: 0.9rem; min-width: 7.5rem; }
.archive-list .word { font-weight: 700; font-family: var(--serif); font-size: 1.02rem; }
.archive-list .count { color: #8e8e93; font-size: 0.85rem; }

/* --- CTA band: a paper inset, flat button --- */
.cta-band {
    background-color: #edf4fb;
    background-image: var(--paper-noise);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 14px;
    text-align: center;
    padding: 2rem 1.25rem;
    margin: 2.5rem 0 0.5rem;
}
.cta-band h2 { margin: 0 0 0.4rem; }
.cta-band p { margin: 0 0 1rem; color: #55555a; }
.cta-button {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 0.7rem 1.6rem;
    border-radius: 999px;
    font-weight: 700;
}
.cta-button:hover { text-decoration: none; opacity: 0.92; }

/* --- pager --- */
.pager { display: flex; justify-content: space-between; margin: 1.5rem 0; }
.pager a { font-weight: 600; }

/* --- footer: sits on the paper, outside the card --- */
.site-footer {
    margin-top: 0;
    padding: 0.25rem 1.25rem 2.5rem;
    text-align: center;
    color: #6d6d74;
    font-size: 0.9rem;
}
.site-footer .footer-links { display: flex; flex-wrap: wrap; gap: 1.1rem; justify-content: center; margin: 0.75rem 0; }
.site-footer a { color: #55555a; }
.footer-copy { font-size: 0.8rem; }

/* --- dark mode: the app's dark purple paper --- */
@media (prefers-color-scheme: dark) {
    body {
        color: #f2f2f7;
        background-color: #1a1128;
        background-image: var(--paper-noise), linear-gradient(180deg, #170f21 0%, #211433 100%);
    }
    a { color: #ffa07a; }
    .site-main {
        background: #221b30;
        border-color: rgba(255, 255, 255, 0.09);
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    }
    .page-head p, .profile-head .stats, .cta-band p { color: #a1a1aa; }
    .img-loading::before { border-color: rgba(255, 255, 255, 0.18); border-top-color: var(--accent); }
    .drawing-card > a, .drawing-hero .art { border-color: rgba(255, 255, 255, 0.12); }
    .drawing-card img, .drawing-hero .art img { background: white; } /* drawings are on white paper */
    .card-byline .byline-name { color: #f2f2f7; }
    .chip { background: #2a2138; border-color: rgba(255, 255, 255, 0.14); }
    .archive-list li { border-color: rgba(255, 255, 255, 0.09); }
    .cta-band { background-color: #2a2138; border-color: rgba(255, 255, 255, 0.07); }
    .site-footer { color: #a1a1aa; }
    .site-footer a { color: #c7c7cf; }
}
