/* Saratay Archive — mobile-first styles */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #eef2ee;
  --hero: #e2ebe6;
  --ink: #1b2b31;
  --ink-2: #3a4c51;
  --muted: #6a7a7d;
  --line: #dfe6e1;
  --brand: #234e49;
  --brand-ink: #ffffff;
  --accent: #2f6d64;
  --accent-soft: #dcebe4;
  --warm: #b3743a;
  --heart: #c4506d;
  --shadow: 0 1px 2px rgb(27 43 49 / .04), 0 8px 24px rgb(27 43 49 / .06);
  --radius: 16px;
  --gutter: 16px;
  --font: 'IBM Plex Sans Thai Looped', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-head: 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-serif: 'DM Serif Display', Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141a1c;
    --surface: #1c2427;
    --surface-2: #232d30;
    --hero: #18211f;
    --ink: #e8eeec;
    --ink-2: #c4cfcc;
    --muted: #8d9c9b;
    --line: #2c383a;
    --brand: #8fc9bc;
    --brand-ink: #10201d;
    --accent: #8fc9bc;
    --accent-soft: #23403a;
    --warm: #e0a46a;
    --heart: #f0849e;
    --shadow: 0 1px 2px rgb(0 0 0 / .2), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 140px; }
html.locked { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--warm); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--brand); color: var(--brand-ink); padding: 10px 16px; border-radius: 10px; }
.skip:focus { top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { margin: 0 0 8px; font: 600 11px/1.4 var(--font-head); letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 22px; border-radius: 999px; font-weight: 600; font-size: 15px; transition: transform .15s, background .2s, box-shadow .2s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 8px 20px rgb(35 78 73 / .22); }
.btn-ghost { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); }
.link-btn { color: var(--accent); font-size: 14px; font-weight: 600; min-height: 44px; padding: 0 4px; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--ink); transition: background .2s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.dark { color: #fff; background: rgb(255 255 255 / .12); }
.icon-btn.dark:hover { background: rgb(255 255 255 / .22); }
.icon-btn:disabled { opacity: .25; cursor: default; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 var(--gutter); padding-top: env(safe-area-inset-top); max-width: 1240px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 10px; margin-right: auto; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font: italic 22px/1 var(--font-serif); padding-top: 2px; }
.brand-text { font: 700 14px/1.1 var(--font-head); letter-spacing: .08em; text-transform: uppercase; }
.brand-text small { display: block; margin-top: 3px; font-size: 9px; font-weight: 600; letter-spacing: .22em; color: var(--muted); }
.top-nav { display: none; }

/* ---------- hero ---------- */
.hero { padding: 28px var(--gutter) 40px; max-width: 1240px; margin: 0 auto; display: grid; gap: 28px; }
.hero-copy { position: relative; }
.hero h1 { margin: 0 0 14px; font: 600 clamp(30px, 8.6vw, 60px)/1.32 var(--font-head); letter-spacing: -.02em; text-wrap: balance; }
.hero h1 em { display: block; font-style: normal; color: var(--accent); }
.lead { margin: 0 0 24px; color: var(--ink-2); font-size: 16px; max-width: 34em; }
.hero-actions .btn { width: 100%; }
.hero-actions svg { width: 18px; height: 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 28px 0 0; border-top: 1px solid var(--line); }
.stats div { padding: 14px 0 0; }
.stats div + div { padding-left: 16px; border-left: 1px solid var(--line); margin-left: 0; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font: 26px/1.2 var(--font-serif); color: var(--brand); }

.hero-art { position: relative; aspect-ratio: 16 / 9.5; margin: 0 4px; }
.polaroid { position: absolute; width: 46%; aspect-ratio: 4 / 5; background: var(--surface); padding: 6px 6px 22px; border-radius: 4px; box-shadow: 0 14px 34px rgb(27 43 49 / .16); }
.polaroid img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; border-radius: 2px; background: var(--surface-2); }
.polaroid img:not([src]) { visibility: hidden; }
.p1 { left: 0; top: 18px; transform: rotate(-6deg); }
.p2 { left: 27%; top: 0; transform: rotate(2deg); z-index: 1; }
.p3 { right: 0; top: 24px; transform: rotate(7deg); }

/* ---------- archive ---------- */
.archive { max-width: 1240px; margin: 0 auto; padding: 32px var(--gutter) 56px; }
.section-head { margin-bottom: 16px; }
.section-head h2, .about h2 { margin: 0 0 6px; font: 600 clamp(26px, 6.5vw, 38px)/1.35 var(--font-head); letter-spacing: -.02em; }
.section-head p.muted { margin: 0; font-size: 15px; }

/* sticky toolbar */
.toolbar { position: sticky; top: 0; z-index: 20; margin: 0 calc(var(--gutter) * -1); padding: 10px var(--gutter); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); transition: box-shadow .2s, border-color .2s; border-bottom: 1px solid transparent; }
.toolbar.stuck { border-color: var(--line); box-shadow: 0 6px 18px rgb(27 43 49 / .06); padding-top: max(10px, env(safe-area-inset-top)); }
.search-row { display: flex; gap: 8px; }
.search { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 6px 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; transition: border-color .2s, box-shadow .2s; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search > svg { color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; }
.search input::placeholder { color: var(--muted); opacity: .8; }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); }
.search-clear:hover { background: var(--surface-2); }
.search-clear svg { width: 18px; height: 18px; }
.filter-toggle { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; }
.filter-toggle .label { display: none; }
.filter-toggle.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.filter-toggle b { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center; border-radius: 10px; background: var(--warm); color: #fff; font-size: 11px; }

.chips { display: flex; gap: 8px; margin: 10px calc(var(--gutter) * -1) 0; padding: 0 var(--gutter) 2px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; -webkit-mask-image: none; mask-image: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 500; white-space: nowrap; scroll-snap-align: start; transition: background .15s, color .15s, border-color .15s; }
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip-count { font-size: 12px; opacity: .65; }
.chip-saved svg { width: 18px; height: 18px; }
.chip-saved.active { background: var(--heart); border-color: var(--heart); color: #fff; }
.chip-saved.active svg { fill: currentColor; }
.chip-saved b { font-weight: 600; font-size: 12px; opacity: .8; }

.filters { margin-top: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 18px; max-height: calc(100dvh - 190px); overflow-y: auto; animation: drop .2s ease-out; }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
.filter-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.filter-selects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field select { width: 100%; min-height: 46px; padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a7a7d' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 18px; appearance: none; font-size: 15px; }
.filter-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.filter-foot .chip-saved { margin-right: auto; }
.apply { width: 100%; min-height: 46px; box-shadow: none; }

.result-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.result-line strong { color: var(--ink); font-weight: 600; }

/* ---------- feed ---------- */
.month-title { display: flex; align-items: baseline; gap: 8px; margin: 28px 0 14px; font: 600 20px/1.3 var(--font-head); }
.month-title small { font: 18px var(--font-serif); color: var(--muted); }
.month-title::after { content: ''; flex: 1; height: 1px; background: var(--line); align-self: center; }
.grid { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); align-self: start; transition: opacity .2s, transform .2s; }
.card.leaving { opacity: 0; transform: scale(.97); }
.card-media { position: relative; display: block; width: 100%; background: var(--surface-2); cursor: zoom-in; overflow: hidden; }
.card-media img { display: block; width: 100%; height: auto; min-height: 200px; max-height: 560px; object-fit: contain; opacity: 0; transition: opacity .35s; }
.card-media.loaded img { opacity: 1; min-height: 0; }
.card-media:not(.loaded) { background: linear-gradient(100deg, var(--surface-2) 30%, var(--bg) 50%, var(--surface-2) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.badge { position: absolute; top: 10px; right: 10px; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px 4px 8px; border-radius: 999px; background: rgb(20 26 28 / .72); color: #fff; font-size: 12px; font-weight: 600; backdrop-filter: blur(6px); }
.badge svg { width: 15px; height: 15px; }
.card-body { padding: 14px 16px 8px; }
.date { display: block; font-size: 13px; font-weight: 600; color: var(--accent); }
.caption { margin: 6px 0 0; font-size: 15.5px; line-height: 1.85; white-space: pre-line; overflow-wrap: anywhere; color: var(--ink-2); }
.caption.clamped { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.empty-caption { color: var(--muted); font-style: italic; font-size: 14px; }
.more { margin-top: 2px; min-height: 40px; color: var(--accent); font-size: 14px; font-weight: 600; }
.card-actions { display: flex; gap: 4px; margin: 6px -8px 0; padding-top: 6px; border-top: 1px solid var(--line); }
.act { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--ink-2); transition: background .15s, color .15s; }
.act:hover { background: var(--surface-2); }
.act svg { width: 19px; height: 19px; }
.act.save[aria-pressed="true"] { color: var(--heart); }
.act.save[aria-pressed="true"] svg { fill: currentColor; animation: pop .3s ease-out; }
@keyframes pop { 50% { transform: scale(1.3); } }

.empty { padding: 56px 16px; text-align: center; }
.empty-icon { margin: 0; font-size: 36px; color: var(--accent); }
.empty-title { margin: 6px 0 4px; font: 600 19px var(--font-head); }
.empty .btn { margin-top: 14px; }

.load-wrap { text-align: center; margin-top: 32px; }
#sentinel { height: 1px; }
.load-wrap .btn { min-width: 220px; }

/* ---------- about & footer ---------- */
.about { max-width: 1240px; margin: 0 auto; padding: 48px var(--gutter); border-top: 1px solid var(--line); }
.about h2 em { display: block; font-style: normal; color: var(--accent); }
.about-body p { margin: 0 0 14px; color: var(--ink-2); max-width: 36em; }
.heart-inline { color: var(--heart); font-weight: 700; }
.foot { max-width: 1240px; margin: 0 auto; padding: 28px var(--gutter) calc(40px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: grid; gap: 10px; }
.foot p { margin: 0; }

/* ---------- floating ---------- */
.fab { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); box-shadow: 0 10px 24px rgb(27 43 49 / .25); animation: rise .2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 500; white-space: nowrap; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- viewer ---------- */
.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0d1112; color: #fff; }
.viewer[open] { display: flex; flex-direction: column; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.viewer::backdrop { background: rgb(0 0 0 / .85); }
.viewer-top { display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 12px 10px 18px; font-size: 14px; color: rgb(255 255 255 / .8); }
.viewer-top span { margin-right: auto; font-variant-numeric: tabular-nums; }
.viewer-link { min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; border: 1px solid rgb(255 255 255 / .22); font-size: 13px; font-weight: 600; color: #fff; }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; touch-action: pan-y pinch-zoom; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); display: none; }
.viewer .prev { left: 12px; }
.viewer .next { right: 12px; }
.viewer-dots { display: flex; justify-content: center; gap: 6px; padding: 14px 0 max(18px, env(safe-area-inset-bottom)); min-height: 20px; }
.viewer-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgb(255 255 255 / .3); transition: background .2s, width .2s; }
.viewer-dots i.on { width: 18px; border-radius: 3px; background: #fff; }

/* ---------- single post page ---------- */
.post-top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.post-top .top { gap: 4px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 12px 0 6px; margin-left: -6px; border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--accent); }
.back:hover { background: var(--surface-2); }
.post-top .back { margin-right: auto; }
.post-top .brand { margin: 0; }
.single { max-width: 720px; margin: 0 auto; padding: 24px var(--gutter) 48px; }
.single .date { font-size: 14px; }
.single h1 { margin: 6px 0 16px; font: 600 clamp(22px, 5.6vw, 34px)/1.5 var(--font-head); letter-spacing: -.01em; text-wrap: pretty; }
.single-actions { display: flex; gap: 8px; margin-bottom: 20px; }
.single-actions .btn { min-height: 44px; padding: 0 18px; font-size: 14px; }
.single-actions svg { width: 18px; height: 18px; }
.single-actions .save[aria-pressed="true"] { color: var(--heart); border-color: color-mix(in srgb, var(--heart) 45%, transparent); }
.single-actions .save[aria-pressed="true"] svg { fill: currentColor; }
.single-caption { margin: 0 0 28px; font-size: 17px; line-height: 2; color: var(--ink-2); overflow-wrap: anywhere; }
.single-images { display: grid; gap: 16px; margin: 0 calc(var(--gutter) * -1) 32px; }
.single-images figure { margin: 0; background: var(--surface); border-block: 1px solid var(--line); }
.single-images img { display: block; margin: 0 auto; max-height: 85vh; height: auto; }
.single-images figcaption { padding: 14px var(--gutter); font-size: 15px; line-height: 1.9; color: var(--ink-2); border-top: 1px solid var(--line); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { display: block; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); min-width: 0; transition: border-color .15s; }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; font-size: 12px; font-weight: 600; color: var(--accent); }
.pager span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.pager .next { text-align: right; grid-column: 2; }
.pager-home { display: flex; justify-content: center; margin-top: 20px; }

/* ================= larger screens ================= */
@media (min-width: 560px) {
  :root { --gutter: 24px; }
  .hero-actions .btn { width: auto; }
  .filter-toggle .label { display: inline; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .single-images { margin-inline: 0; }
  .single-images figure { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
}
@media (min-width: 860px) {
  :root { --gutter: 40px; }
  html { scroll-padding-top: 120px; }
  .top { height: 76px; }
  .top-nav { display: flex; gap: 4px; margin-right: 8px; }
  .top-nav a { padding: 10px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
  .top-nav a:hover { background: var(--surface-2); }
  .hero { grid-template-columns: 1.1fr .9fr; align-items: center; gap: 56px; padding-top: 48px; padding-bottom: 72px; }
  .hero h1 { font-size: clamp(40px, 4.6vw, 60px); }
  .lead { font-size: 17px; }
  .hero-art { aspect-ratio: 1 / .95; }
  .polaroid { width: 52%; padding: 10px 10px 34px; }
  .p1 { top: 14%; } .p2 { left: 24%; top: 0; } .p3 { top: 22%; }
  .archive { padding-top: 56px; }
  .toolbar { padding-top: 14px; padding-bottom: 14px; }
  .filters { grid-template-columns: 1fr auto; align-items: start; column-gap: 28px; }
  .filter-selects { grid-template-columns: 170px 170px; }
  .filter-foot { grid-column: 1 / -1; }
  .apply { display: none; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
  .month-title { margin-top: 40px; font-size: 22px; }
  .about { display: grid; grid-template-columns: 1fr 1fr; column-gap: 64px; padding-block: 72px; }
  .about .eyebrow { grid-column: 1 / -1; }
  .foot { grid-template-columns: auto 1fr; align-items: center; }
  .foot p { text-align: right; }
  .viewer .nav { display: grid; }
  .viewer-stage { padding: 0 72px; }
  .fab { right: 28px; bottom: 28px; }
  .single { padding-top: 40px; }
}
@media (min-width: 1180px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (hover: none) {
  .chip:hover, .btn-ghost:hover, .pager a:hover { border-color: var(--line); }
  .chip.active:hover { border-color: var(--brand); }
}
