/* Salimbogram base styles (spec 4). All colour and spacing values come from
   the design tokens; --sg-* aliases re-point at theme.json presets so the
   accent is configured in exactly one place (4.1). */

:root {
  --sg-bg: #ffffff;
  --sg-text: #111111;
  --sg-text-body: #1f1f1f;
  --sg-text-muted: #5f6368;
  --sg-line: #e6e6e6;
  --sg-surface: #f2f2f2;
  --sg-placeholder: #d9dee3;
  --sg-accent: #2f6fed;
  --sg-viewer-bg: #0b0b0b;
  --sg-viewer-text: #ededed;
  --sg-radius-s: 4px;
  --sg-radius-m: 8px;
  --sg-content: 660px;
  --sg-wide: 1000px;
  --sg-page: 935px;
  --sg-font-ui: 'DM Sans', -apple-system, 'Segoe UI', sans-serif;
  --sg-font-reading: 'Source Serif 4', Georgia, serif;
}

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

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

body {
  margin: 0;
  background: var(--sg-bg);
  color: var(--sg-text);
  font-family: var(--sg-font-ui);
  font-size: 15px;
  line-height: 1.4;
}

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

/* -------- Photo boxes (4.4): fixed ratio, blur preview, 200 ms fade ------- */

.sg-img {
  display: block;
  background-color: var(--sg-placeholder);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.sg-img img { width: 100%; height: 100%; }
.sg-img picture, .sg-img source { display: contents; }
@media (prefers-reduced-motion: no-preference) {
  .sg-img img { animation: sg-fade 200ms ease-out; }
}
@keyframes sg-fade { from { opacity: 0; } to { opacity: 1; } }

a { color: var(--sg-accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

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

.screen-reader-text {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* Skip-to-content (4.6) */
.sg-skip {
  position: absolute; left: 8px; top: -48px; z-index: 200;
  background: var(--sg-bg); color: var(--sg-text);
  padding: 8px 12px; border-radius: var(--sg-radius-m);
  transition: top 150ms ease-out;
}
.sg-skip:focus { top: 8px; }

.sg-screen-reader, .sg-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* -------- Header / site bar ------------------------------------------------ */

.sg-bar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 52px; padding: 0 16px;
  background: var(--sg-bg);
  border-bottom: 1px solid var(--sg-line);
}
.sg-bar-name { font-size: 20px; font-weight: 700; line-height: 1.2; }
.sg-bar-name a { color: var(--sg-text); }
.sg-bar-nav { display: none; }
.sg-bar-nav ul {
  display: flex; gap: 24px; align-items: center;
  list-style: none; margin: 0; padding: 0;
}
.sg-bar-nav a { color: var(--sg-text); font-size: 15px; }
.sg-bar-menu {
  /* 44 px touch target (4.5) */
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin: 0 -8px 0 0;
  background: none; border: 0; color: var(--sg-text); cursor: pointer;
}
.sg-bar-menu svg { width: 24px; height: 24px; }

.sg-progress-line {
  position: absolute; left: 0; bottom: -1px; height: 2px;
  width: var(--sg-progress, 0%);
  background: var(--sg-accent);
}

.sg-mobile-nav {
  position: absolute; right: 8px; top: 52px; z-index: 60;
  background: var(--sg-bg); border: 1px solid var(--sg-line);
  border-radius: var(--sg-radius-m);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.08);
  min-width: 180px;
}
.sg-mobile-nav ul { list-style: none; margin: 0; padding: 8px 0; }
.sg-mobile-nav a { display: block; padding: 10px 16px; color: var(--sg-text); }
.sg-progress-line {
  position: absolute; left: 0; bottom: -1px;
  height: 2px; width: var(--sg-progress, 0%);
  background: var(--sg-accent);
}
@media (prefers-reduced-motion: no-preference) {
  .sg-progress-line { transition: width 150ms ease-out; }
}

/* -------- Profile header (PR-1..PR-3; 4.3 phone sizes) ------------------- */

.sg-main { max-width: var(--sg-page); margin: 0 auto; }

.sg-profile {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 16px 16px;
}
.sg-avatar { flex: 0 0 auto; width: 76px; height: 76px; }
.sg-avatar-img {
  width: 76px; height: 76px; border-radius: 50%;
  border: 1px solid var(--sg-line);
  overflow: hidden;
}
.sg-avatar-img img { width: 100%; height: 100%; object-fit: cover; }
.sg-avatar-empty { display: block; background: var(--sg-surface); }

.sg-profile-text { flex: 1 1 auto; min-width: 0; }
.sg-name { margin: 0 0 2px; font-size: 20px; font-weight: 700; line-height: 1.2; }
.sg-bio { margin: 0 0 6px; color: var(--sg-text); font-size: 14px; }
.sg-counts { display: flex; gap: 16px; margin: 0; font-size: 14px; }
.sg-counts strong { font-weight: 600; }

/* -------- Story rail (ST-1) ------------------------------------------------- */

.sg-rail { position: relative; }
.sg-rail-track {
  display: flex; gap: 6px;
  margin: 0; padding: 0 12px 12px;
  list-style: none;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sg-rail-track::-webkit-scrollbar { display: none; }
.sg-story-item { flex: 0 0 auto; }
.sg-story-link {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 76px; padding: 4px 0; color: var(--sg-text);
}
.sg-story-link:hover { text-decoration: none; }
.sg-ring {
  display: block; width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--sg-accent);
  padding: 3px; background: var(--sg-bg);
}
.sg-ring .sg-img { width: 52px; height: 52px; border-radius: 50%; }
.sg-ring-img img { border-radius: 50%; object-fit: cover; }
.sg-ring-empty { display: block; width: 52px; height: 52px; border-radius: 50%; background: var(--sg-surface); }
.sg-story-name {
  font-size: 12px; line-height: 1.2; max-width: 76px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sg-rail-arrow {
  position: absolute; top: 20px; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  background: var(--sg-bg); border: 1px solid var(--sg-line); border-radius: 50%;
  color: var(--sg-text); cursor: pointer;
}
.sg-rail-arrow[hidden] { display: none !important; }
.sg-rail-arrow:hover { background: var(--sg-surface); }
.sg-rail-prev { left: 8px; }
.sg-rail-next { right: 8px; }
/* The last circle is cut off at the edge to signal scrolling (4.3): the
   track's right padding is 0 and items are wider than the 6 px gap. */

/* -------- Tabs ---------------------------------------------------------------- */

.sg-tabs { border-bottom: 1px solid var(--sg-line); }
.sg-tabs ul {
  display: flex; justify-content: center; gap: 32px;
  list-style: none; margin: 0; padding: 0 16px;
}
.sg-tabs a {
  display: block; padding: 12px 0 10px;
  color: var(--sg-text-muted); font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.sg-tabs a[aria-current="page"] { color: var(--sg-text); border-bottom-color: var(--sg-text); }
.sg-tabs a:hover { text-decoration: none; color: var(--sg-text); }

/* -------- Photo grid (GR-1..GR-4) ------------------------------------------- */

.sg-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  margin: 0;
}
.sg-tile { position: relative; display: block; color: #fff; }
.sg-tile:hover { text-decoration: none; }
.sg-tile .sg-img { width: 100%; }
.sg-tile .sg-img img { object-fit: cover; object-position: var(--fx, 50%) var(--fy, 50%); }

.sg-marks { position: absolute; top: 6px; right: 6px; display: flex; flex-direction: column; gap: 6px; }
.sg-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  color: #fff;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.35));
}
.sg-mark svg { width: 16px; height: 16px; }

.sg-grid-wrap { }
.sg-load-more {
  display: block; width: fit-content; margin: 24px auto 40px;
  padding: 10px 20px;
  border: 1px solid var(--sg-line); border-radius: var(--sg-radius-m);
  color: var(--sg-text); font-size: 14px;
  text-align: center;
}

/* -------- Photo & story viewers: dark overlay (VI-1, ST-2) ------------------ */

.sg-viewer {
  position: fixed; inset: 0; z-index: 100;
  background: var(--sg-viewer-bg); color: var(--sg-viewer-text);
  display: flex; flex-direction: column;
}
.sg-viewer[hidden] { display: none; }
.sg-viewer-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; min-height: 52px;
}
.sg-viewer-count { font-size: 13px; color: var(--sg-viewer-text); }
.sg-viewer-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.sg-viewer-stage img { max-height: 100%; max-width: 100%; object-fit: contain; }
.sg-viewer-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0;
  background: none; border: 0; color: var(--sg-viewer-text); cursor: pointer;
}
.sg-viewer-caption {
  padding: 8px 16px 16px;
  font-size: 13px; color: var(--sg-viewer-text); text-align: center;
}
.sg-viewer-caption .sg-chips { justify-content: center; }
.sg-viewer-caption .sg-chip { background: rgb(255 255 255 / 0.12); color: var(--sg-viewer-text); }
.sg-viewer-dots { display: flex; gap: 6px; justify-content: center; padding: 0 0 12px; margin: 0; list-style: none; }
.sg-viewer-dots button {
  width: 24px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer;
  position: relative;
}
.sg-viewer-dots button::after {
  content: ''; position: absolute; inset: 8px;
  border-radius: 50%; background: rgb(255 255 255 / 0.4);
}
.sg-viewer-dots button[aria-current="true"]::after { background: #fff; }

/* -------- Chips (PO-5) ------------------------------------------------------- */

.sg-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  list-style: none; margin: 0; padding: 0;
}
.sg-chip {
  background: var(--sg-surface);
  font-size: 12px; line-height: 1.4;
  padding: 4px 10px; border-radius: var(--sg-radius-m);
  white-space: nowrap;
}

/* -------- Post page (PO-2) ---------------------------------------------------- */

.sg-post { max-width: var(--sg-content); margin: 0 auto; padding: 0 20px 56px; }

.sg-back { margin: 16px 0 0; }
.sg-back a { color: var(--sg-text); font-size: 14px; }
.sg-post-title-block { margin: 24px 0 16px; }
.sg-collection-label {
  display: inline-block; margin-bottom: 4px;
  font-size: 12px; line-height: 1; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--sg-accent);
}
.sg-post-title {
  margin: 0 0 12px;
  font-size: 28px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em;
}
.sg-meta-line { margin: 0 0 12px; color: var(--sg-text-muted); font-size: 13px; }
.sg-meta-line a { color: var(--sg-text-muted); }
.sg-meta-line a { text-decoration: underline; text-underline-offset: 2px; }
.sg-meta-line a:hover { color: var(--sg-text); }

.sg-hero { margin: 0 -20px 24px; }
.sg-hero .sg-img { }
.sg-hero .sg-img img { object-fit: contain; }

.sg-carousel { margin: 0 -20px 24px; }
.sg-slides {
  display: flex; gap: 0; overflow-x: auto;
  scroll-snap-type: x mandatory;
  list-style: none; margin: 0; padding: 0;
  scrollbar-width: none;
}
.sg-slides::-webkit-scrollbar { display: none; }
.sg-slide { flex: 0 0 100%; scroll-snap-align: center; }
.sg-slide .sg-img { margin: 0 auto; }
.sg-dots {
  display: flex; gap: 8px; justify-content: center;
  margin: 12px 0 0; padding: 0; list-style: none;
}
.sg-dot {
  width: 24px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer; position: relative;
}
.sg-dot::after {
  content: ''; position: absolute; inset: 9px;
  border-radius: 50%; background: var(--sg-line);
}
.sg-dot.is-on::after { background: var(--sg-accent); }

/* Body (PO-3) */
.sg-body {
  font-family: var(--sg-font-reading);
  font-size: 18px; line-height: 1.7; color: var(--sg-text-body);
  margin: 24px 0 32px;
}
.sg-body > * + * { margin-top: 1em; }
.sg-body h2, .sg-body h3 {
  font-family: var(--sg-font-ui);
  font-size: 22px; font-weight: 600; line-height: 1.25;
  margin-top: 1.6em; color: var(--sg-text);
}
.sg-body p { margin: 0; }
.sg-body a { color: var(--sg-accent); text-decoration: underline; text-underline-offset: 2px; }
.sg-body figure { margin: 1.6em -20px; font-family: var(--sg-font-ui); }
.sg-body figcaption {
  padding: 8px 20px 0;
  font-size: 13px; line-height: 1.4; color: var(--sg-text-muted);
}
.sg-body .sg-figure-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 1.6em -20px; }
.sg-body .sg-figure-pair figure { margin: 0; }
.sg-body blockquote, .sg-body .sg-pullquote {
  font-family: var(--sg-font-ui); font-size: 24px; font-weight: 500; line-height: 1.3;
  color: var(--sg-text);
  margin: 1.6em 0; padding: 0 8px;
  text-align: center;
}

.sg-post-foot { font-family: var(--sg-font-ui); border-top: 1px solid var(--sg-line); padding-top: 16px; }
.sg-social-line { color: var(--sg-text-muted); font-size: 13px; margin: 0 0 24px; }
.sg-social-line a { text-decoration: underline; text-underline-offset: 2px; }
.sg-more h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--sg-text-muted); margin: 0 0 12px; }
.sg-more .sg-grid { gap: 2px; }
.sg-more .sg-tile .sg-img { border-radius: var(--sg-radius-s); }
.sg-prev-next {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--sg-line);
  font-size: 14px;
}
.sg-prev-next a { color: var(--sg-text); }

/* -------- Stories tab (ST-6) ----------------------------------------------- */

.sg-collections-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 16px;
}
.sg-collection-cover {
  position: relative; display: block; overflow: hidden;
  border-radius: var(--sg-radius-s); color: #fff;
}
.sg-collection-cover:hover { text-decoration: none; }
.sg-collection-cover .sg-img { width: 100%; height: 100%; }
.sg-collection-cover .sg-img img { object-fit: cover; }
.sg-collection-cover-name, .sg-collection-cover-count {
  position: absolute; left: 12px; text-shadow: 0 1px 4px rgb(0 0 0 / 0.55);
}
.sg-collection-cover-name { bottom: 28px; font-size: 15px; font-weight: 600; }
.sg-collection-cover-count { bottom: 10px; font-size: 12px; }

/* -------- Places list (GR-5 / tab) ------------------------------------------ */

.sg-places { list-style: none; margin: 0; padding: 8px 16px 32px; }
.sg-places li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--sg-line);
}
.sg-places a { color: var(--sg-text); font-weight: 600; }
.sg-place-count { color: var(--sg-text-muted); font-size: 13px; flex: 0 0 auto; }

/* About page */
.sg-about { padding: 24px 20px 56px; max-width: var(--sg-content); margin: 0 auto; }

.sg-about .sg-body > * + * { margin-top: 1em; }
.sg-about-photo .sg-img { border-radius: var(--sg-radius-s); }
.sg-about-photo { margin-bottom: 20px; }

/* -------- Footer --------------------------------------------------------------- */

.sg-footer {
  max-width: var(--sg-page); margin: 40px auto 0; padding: 24px 16px 32px;
  border-top: 1px solid var(--sg-line);
  color: var(--sg-text-muted); font-size: 13px;
}
.sg-footer a { color: var(--sg-text-muted); }

/* -------- Desktop (PR-4, 4.3 at 1280 px) --------------------------------------- */

@media (min-width: 780px) {
  body { font-size: 16px; }

  .sg-bar { height: 64px; padding: 0 24px; }
  .sg-bar-name { font-size: 24px; }
  .sg-bar-menu { display: none; }          /* desktop: top bar nav, no menu button */
  .sg-bar-nav { display: block; }

  .sg-profile { gap: 28px; padding: 40px 24px 24px; }
  .sg-avatar, .sg-avatar-img { width: 120px; height: 120px; }
  .sg-name { font-size: 24px; }

  .sg-rail-track { gap: 14px; padding: 0 24px 16px; }
  .sg-story-link { width: 96px; }
  .sg-ring { width: 80px; height: 80px; }
  .sg-ring .sg-img, .sg-ring-empty { width: 60px; height: 60px; }

  .sg-tabs { text-align: center; }
  .sg-tabs ul { justify-content: center; }
  .sg-tabs a { font-size: 13px; letter-spacing: 0.08em; }

  .sg-grid { gap: 4px; padding: 4px 24px 0; }
  .sg-tile .sg-img { border-radius: var(--sg-radius-s); }

  .sg-post { padding: 0 24px 72px; }
  .sg-post-title-block { margin: 40px 0 24px; text-align: center; }
  .sg-collection-label { font-size: 13px; letter-spacing: 0.06em; }
  .sg-post-title { font-size: 44px; }
  .sg-meta-line { font-size: 14px; }
  .sg-chips { justify-content: center; font-size: 14px; }

  .sg-hero, .sg-carousel { margin-left: 0; margin-right: 0; margin-bottom: 32px; }
  .sg-hero .sg-img { border-radius: var(--sg-radius-s); }

  .sg-body { font-size: 20px; }
  .sg-body h2, .sg-body h3 { font-size: 28px; }
  .sg-body blockquote, .sg-body .sg-pullquote { font-size: 30px; margin-left: -60px; margin-right: -60px; }
  .sg-body figure { margin-left: -20px; margin-right: -20px; }
  .sg-body .sg-figure-pair,
  .sg-body .sg-figure-gallery { margin-left: -170px; margin-right: -170px; } /* widen to 1000 px */
  .sg-body .sg-figure-pano { margin-left: -270px; margin-right: -270px; }   /* widen to 1200 px */
  .sg-body figcaption { padding: 8px 0 0; }

  .sg-footer { padding: 24px 32px; }

  .sg-about { display: grid; grid-template-columns: 320px 1fr; gap: 32px; padding: 40px 0 80px; }
  .sg-about-photo { margin-bottom: 0; }
}
