/* Joudran al Thawra — site styles. English (LTR) and Arabic (RTL).
   Tokens: concrete-light paper, dark ink, one spray-red accent. */
:root {
  --paper: #EDECE8;
  --paper-2: #FFFFFF;
  --ink: #1C1A17;
  --mid: #6B675F;
  --rule: #CBC7BE;
  --spray: #CF1F2B;
  --display: "Anton", "Arial Narrow", Impact, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --arabic: "IBM Plex Sans Arabic", "Noto Naskh Arabic", "Segoe UI", sans-serif;
  --arabic-display: "Lalezar", "IBM Plex Sans Arabic", sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --maxw: 1320px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #1B1A18; --paper-2: #242320; --ink: #ECE9E2; --mid: #9C978E; --rule: #3B3934; --spray: #E8404B; }
}
:root[data-theme="dark"] { --paper: #1B1A18; --paper-2: #242320; --ink: #ECE9E2; --mid: #9C978E; --rule: #3B3934; --spray: #E8404B; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.55; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration-color: var(--spray); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--spray); }
:focus-visible { outline: 3px solid var(--spray); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; letter-spacing: 0.01em; line-height: 1; margin: 0 0 0.4em; }
h1 { font-size: clamp(40px, 7vw, 88px); }
h2 { font-size: clamp(26px, 3.4vw, 40px); }
h3 { font-size: clamp(20px, 2.4vw, 28px); }
p { margin: 0 0 1em; }
code { font-size: 0.9em; background: var(--paper-2); padding: 0 .3em; border: 1px solid var(--rule); }
.muted { color: var(--mid); }
.alt-name { display: block; font-size: 0.45em; color: var(--mid); margin-top: .2em; letter-spacing: 0; }
.alt-name:lang(ar) { font-family: var(--arabic-display); }
.alt-name:lang(en) { font-family: var(--display); }
.place-tile .alt-name { font-size: 14px; margin: 0 0 4px; }
.skip { position: absolute; inset-inline-start: 8px; top: 0; transform: translateY(-120%); background: var(--spray); color: #fff; padding: .5em 1em; z-index: 100; }
.skip:focus { transform: none; }

/* header / footer */
.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5em 1.5em; padding: 18px var(--gutter); border-bottom: 3px solid var(--ink); }
.brand { font-family: var(--display); font-size: 28px; text-decoration: none; letter-spacing: .02em; }
.nav { display: flex; flex-wrap: wrap; gap: 0 1.2em; margin-inline-start: auto; font-size: 15px; }
.brand-other { font-family: var(--arabic-display); font-size: 0.8em; color: var(--spray); margin-inline-start: .35em; letter-spacing: 0; }
.brand-other:lang(en) { font-family: var(--display); }
.lang { font-size: 15px; text-decoration: none; border: 2px solid var(--ink); padding: 1px 10px; }
.lang:hover { background: var(--ink); color: var(--paper); }
.lang:lang(ar) { font-family: var(--arabic); }
.lang:lang(en) { font-family: var(--body); }
.nav a { text-decoration: none; padding: .2em 0; border-bottom: 2px solid transparent; }
.nav a[aria-current="page"] { border-bottom-color: var(--spray); }
.foot { padding: 32px var(--gutter) 48px; border-top: 1px solid var(--rule); color: var(--mid); font-size: 14px; margin-top: 64px; }
.foot p { max-width: 70ch; }
main { padding: 0 var(--gutter); max-width: var(--maxw); margin: 0 auto; }

/* page headers */
.ph { padding: 40px 0 16px; max-width: 72ch; }
.ph .lede, .lede { font-size: 1.15em; line-height: 1.45; max-width: 60ch; }
.crumb { font-size: 14px; color: var(--mid); margin-bottom: 0.3em; }
.crumb a { text-decoration: none; }
.notes { max-width: 68ch; }

/* photo grid: justified rows, each card grows by its aspect ratio */
.grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 32px; }
.card { flex: calc(var(--r) * 100) 1 calc(var(--r) * 180px); max-width: min(100%, calc(var(--r) * 380px)); text-decoration: none; }
.card figure { margin: 0; background: var(--paper-2); }
.card img { width: 100%; aspect-ratio: var(--r); object-fit: cover; }
.card figcaption { display: flex; justify-content: space-between; gap: 1em; font-size: 13px; padding: 6px 2px 0; color: var(--mid); }
.card .day { font-family: var(--display); color: var(--ink); font-size: 15px; letter-spacing: .02em; }
.card:hover .day { color: var(--spray); }
.grid::after { content: ""; flex: 100 1 auto; } /* keeps the last row from stretching */

/* the stamp */
.stamp { border-top: 3px solid var(--ink); padding-top: 10px; }
.stamp-day { font-family: var(--display); font-size: clamp(44px, 6vw, 72px); line-height: .95; color: var(--spray); }
.stamp-when { font-family: var(--display); font-size: clamp(20px, 2.2vw, 26px); margin-top: 6px; }
.stamp-where { margin-top: 8px; line-height: 1.4; }
.stamp-where a { text-decoration: none; border-bottom: 2px solid var(--spray); }

/* day strip */
.daystrip { margin: 18px 0 8px; }
.ticks { display: flex; align-items: flex-end; height: 56px; border-bottom: 2px solid var(--ink); overflow: hidden; }
.tick { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; text-decoration: none; position: relative; }
.tick span { display: block; width: max(1px, 70%); margin-inline: auto; height: var(--h, 0%); background: var(--mid); min-height: 0; }
.tick.has span { background: var(--ink); }
.tick:hover span, .tick.active span { background: var(--spray); }
.tick:not(.has) span { height: 2px; background: var(--rule); }
.tick[data-month]::before { content: ""; position: absolute; bottom: -2px; inset-inline-start: 0; width: 1px; height: 8px; background: var(--spray); }
.strip-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--mid); padding-top: 4px; }

/* photo page */
.photo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px 40px; padding-top: 28px; }
@media (min-width: 900px) { .photo { grid-template-columns: minmax(0, 7fr) minmax(260px, 3fr); } .photo .hero-fig { grid-row: 1 / span 3; } }
.hero-fig { margin: 0; }
.hero-fig img { width: 100%; aspect-ratio: var(--r); object-fit: contain; background: var(--paper-2); max-height: 86vh; }
.zoom { cursor: zoom-in; display: block; }
.side { display: flex; flex-direction: column; gap: 20px; }
.pn { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; border-top: 1px solid var(--rule); padding-top: 10px; }
.pn a[aria-disabled="true"] { color: var(--rule); text-decoration: none; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; text-decoration: none; border: 1px solid var(--ink); padding: 2px 10px; border-radius: 999px; }
.chip:hover { background: var(--ink); color: var(--paper); }
.words h1 { font-size: clamp(30px, 4vw, 48px); }
.graffiti-text { font-size: clamp(28px, 4vw, 44px); line-height: 1.25; font-weight: 600; margin: 0 0 .3em; }
.graffiti-text:lang(ar), .graffiti-text[dir="auto"] { font-family: var(--arabic); }
.translation { font-size: 1.15em; color: var(--mid); font-style: italic; }
.caption { max-width: 60ch; }
.details { grid-column: 1 / -1; border-top: 1px solid var(--rule); padding-top: 16px; }
.details h2 { font-size: 22px; }
.details dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 24px; font-size: 15px; max-width: 90ch; }
.details dt { color: var(--mid); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.cite { font-size: 14px; }

/* wall sequence (photo page) */
.wall-seq { grid-column: 1 / -1; }
.wall-seq h2 { font-size: 22px; }
.seq { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.seq-item { flex: 0 0 auto; width: 120px; text-decoration: none; font-size: 13px; }
.seq-item img { width: 120px; height: 90px; object-fit: cover; border: 3px solid transparent; }
.seq-item.current img { border-color: var(--spray); }
.seq-item span { display: block; padding-top: 4px; font-family: var(--display); }
/* strips: photos side by side at one height, scrolled sideways */
.strip { display: flex; gap: 2px; overflow-x: auto; position: relative; }
.strip > a, .strip img { flex: 0 0 auto; display: block; height: 100%; width: auto; max-width: none; }
.strip.full { height: min(70vh, 720px); margin: 8px 0 32px; }
.strip.mini { height: 120px; }
.strip .current img { outline: 4px solid var(--spray); outline-offset: -4px; }
.strip-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.strip-tile { display: block; text-decoration: none; color: inherit; }
.strip-tile .strip { height: 110px; overflow: hidden; }
.strip-tile-text { display: block; padding-top: 6px; }

/* wall page: vertical ledger */
.wall-seq-full { display: flex; flex-direction: column; gap: 0; max-width: 1100px; }
.visit { padding: 20px 0; }
.visit-head { font-size: 20px; margin: 0 0 10px; }
.visit-head .day { color: var(--spray); }
.visit-strip { height: min(55vh, 520px); }
.visit-words { margin-top: 12px; }
.gap { font-family: var(--display); font-size: 20px; color: var(--mid); padding-block: 8px; padding-inline: 18px 0; border-inline-start: 3px solid var(--spray); margin-inline-start: 8px; }
.visit-words .graffiti-text { font-size: clamp(22px, 3vw, 32px); }

/* walls / places index */
.wall-group { margin: 32px 0; }
.wall-list, .place-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.wall-tile, .place-tile { text-decoration: none; display: block; background: var(--paper-2); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.pair.one { grid-template-columns: 1fr; }
.pair img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.wall-tile-text, .place-tile span { display: block; padding: 10px 12px 12px; font-size: 14px; color: var(--mid); }
.wall-tile-text strong, .place-tile strong { display: block; color: var(--ink); font-size: 17px; font-weight: 600; }
.wall-tile:hover strong, .place-tile:hover strong { color: var(--spray); }
.place-tile img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.dayhead { margin-top: 28px; }
.dayhead .day { color: var(--spray); margin-inline-end: .3em; }
.dayhead .muted { font-family: var(--body); font-size: 15px; margin-inline-start: .6em; }

/* timeline */
.months { position: sticky; top: 0; z-index: 5; background: var(--paper); display: flex; gap: 1.2em; overflow-x: auto; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 15px; white-space: nowrap; }
.months a { text-decoration: none; }
.month > h2 { margin-top: 36px; }
.dayblock { scroll-margin-top: 60px; }

/* map */
.map-page main { max-width: none; padding: 0; }
.mapwrap { display: grid; grid-template-columns: minmax(0, 1fr); height: calc(100vh - 70px); min-height: 480px; }
@media (min-width: 900px) { .mapwrap { grid-template-columns: minmax(0, 1fr) 340px; } }
#map { min-height: 60vh; background: #DDD; }
/* Leaflet 1.9 blends tiles with plus-lighter, which turns them white over this page; leaflet.css loads later, so force it */
.leaflet-container .leaflet-tile { mix-blend-mode: normal !important; }
/* mute the map (OSM roads are yellow, orange and red) so the walls stand out */
.leaflet-tile-pane { filter: grayscale(0.85) brightness(1.05) contrast(0.9); }
.map-side { padding: 20px var(--gutter); overflow-y: auto; border-inline-start: 1px solid var(--rule); font-size: 15px; }
.map-side h1 { font-size: 36px; }
.map-list-item { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--rule); text-decoration: none; }
.map-list-item img { width: 56px; height: 42px; object-fit: cover; }
.map-list-item small { display: block; color: var(--mid); }
.leaflet-popup-content { font-family: var(--body); margin: 10px; }
.leaflet-popup-content img { width: 200px; height: 150px; object-fit: cover; margin-bottom: 6px; }
.leaflet-popup-content a { color: var(--ink); font-weight: 600; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(207,31,43,.35); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: var(--spray); color: #fff; font-family: var(--display); font-size: 14px; }

/* search */
.search { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.search input, .search select { font: inherit; font-size: 16px; padding: 8px 10px; border: 2px solid var(--ink); background: var(--paper-2); color: var(--ink); }
.search #q { flex: 1 1 260px; }
.search label { font-size: 14px; color: var(--mid); }

/* prose */
.prose { max-width: 68ch; padding-top: 40px; }
.prose h1 { font-size: clamp(36px, 5vw, 64px); }
.essay-list { list-style: none; padding: 0; max-width: 68ch; }
.essay-list li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.essay-list a { font-family: var(--display); font-size: 26px; text-decoration: none; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(10,10,10,.95); display: grid; place-items: center; z-index: 50; cursor: zoom-out; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.lightbox[hidden] { display: none; }

/* ------- landing: editorial ------- */
.landing-editorial main { max-width: none; padding: 0; }
.hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .hero { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); } }
.hero-img img { width: 100%; height: min(78vh, 820px); object-fit: cover; }
.hero-text { padding: 28px var(--gutter); display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; }
.hero-text h1 { font-size: clamp(44px, 6vw, 84px); }
.hero-text .lede { margin: 0; }
.hero-text .stamp { margin-top: 12px; }
.intro, .doors, .strip-sample, .landing-switch { padding: 0 var(--gutter); max-width: var(--maxw); margin-left: auto; margin-right: auto; }
.intro { padding-top: 40px; }
.doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 2px; margin: 32px auto; }
.door { display: block; text-decoration: none; background: var(--paper-2); padding: 22px 22px 26px; border-top: 3px solid var(--ink); }
.door:hover { border-top-color: var(--spray); }
.door h2 { font-size: 34px; }
.door p { color: var(--mid); font-size: 15px; margin: 0; }
.door .daystrip { margin-top: 14px; } .door .ticks { height: 36px; } .door .strip-ends { display: none; }
.door-pairs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; margin-top: 14px; }
.door-pairs img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.strip-sample h2 { margin-top: 24px; }
.landing-switch { font-size: 13px; color: var(--mid); margin-top: 48px; padding-top: 16px; }

/* ------- landing: mosaic ------- */
.landing-mosaic main { max-width: none; padding: 0; }
.landing-mosaic .top { display: none; }
.mosaic-title { position: fixed; inset-inline-start: 0; bottom: 0; z-index: 10; background: var(--ink); color: var(--paper); padding: 14px 20px 16px; max-width: 360px; }
.mosaic-title h1 { font-size: 34px; margin-bottom: .1em; }
.mosaic-title p { margin: 0; font-size: 14px; }
.mosaic-title a { color: inherit; margin-inline-end: 1em; }
.mosaic { columns: 5 240px; column-gap: 3px; padding: 3px; }
.mosaic .card { display: block; break-inside: avoid; margin-bottom: 3px; position: relative; }
.mosaic .card img { aspect-ratio: auto; }
.mosaic .card figcaption { position: absolute; inset: auto 0 0 0; padding: 40px 10px 10px; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; opacity: 0; transition: opacity .15s; }
.mosaic .card figcaption .day { color: #fff; font-size: 20px; }
.mosaic .card:hover figcaption, .mosaic .card:focus figcaption { opacity: 1; }
.landing-mosaic .landing-switch { padding: 20px; }
.landing-mosaic .foot { display: none; }

/* ------- landing: timeline ------- */
.tl-hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px 40px; padding: 48px 0 24px; align-items: end; }
@media (min-width: 900px) { .tl-hero { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.tl-hero .stamp-day { margin: 0; }
.tl-hero h1 { font-size: clamp(40px, 6vw, 80px); }
.tl-hero-img img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }

/* ------- landing: map ------- */
.landing-map .mapwrap.full { height: calc(100vh - 70px); }
.landing-map .map-side h1 { font-size: 40px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .top, .foot, .nav, .pn, .landing-switch { display: none; } }

/* ------- Arabic (RTL) ------- */
html[lang="ar"] body { font-family: var(--arabic); font-size: 18px; line-height: 1.7; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3,
html[lang="ar"] .brand, html[lang="ar"] .stamp-day, html[lang="ar"] .stamp-when,
html[lang="ar"] .card .day, html[lang="ar"] .seq-item span, html[lang="ar"] .gap,
html[lang="ar"] .essay-list a, html[lang="ar"] .dayhead .day {
  font-family: var(--arabic-display); letter-spacing: 0; font-weight: 400;
}
html[lang="ar"] h1 { line-height: 1.15; }
html[lang="ar"] h2, html[lang="ar"] h3 { line-height: 1.25; }
html[lang="ar"] .stamp-day { line-height: 1.1; }
html[lang="ar"] .translation { font-style: normal; }
html[lang="ar"] .dayhead .muted { font-family: var(--arabic); }
html[lang="ar"] .foot, html[lang="ar"] .muted, html[lang="ar"] .crumb { line-height: 1.6; }
/* Latin text inside Arabic pages keeps Latin fonts */
html[lang="ar"] [lang="en"] { font-family: var(--body); }
html[lang="ar"] h1[lang="en"], html[lang="ar"] [lang="en"] h1, html[lang="ar"] [lang="en"] h2, html[lang="ar"] .essay-list [lang="en"] a { font-family: var(--display); }
html[lang="en"] [lang="ar"] { font-family: var(--arabic); }
.fallback { padding-top: 24px; }
.prose-after { max-width: 68ch; }
/* Display names in the other language keep their display face (must follow the rules above) */
html[lang] .brand-other[lang="ar"], html[lang] .alt-name[lang="ar"] { font-family: var(--arabic-display); }
html[lang] .brand-other[lang="en"], html[lang] .alt-name[lang="en"] { font-family: var(--display); }
.discuss { margin-top: 12px; }
