/* ============================================================
   Thumbnail Grabber — shared styles
   Theme: darkroom contact sheet (dark ink shell, paper panels)
   Mobile-first, then progressively enhanced for desktop.
   ============================================================ */

:root {
  --ink: #17181c;
  --ink-soft: #1f2126;
  --paper: #f3efe6;
  --paper-dim: #e0dacb;
  --rule-soft: #2a2c31;
  --amber: #e2a63b;
  --amber-dim: #a8761f;
  --rose: #c9605a;
  --text-on-ink: #edeae2;
  --text-on-ink-dim: #a9aab1;
  --text-on-paper: #1e1c18;
  --text-on-paper-dim: #4f4a40;

  --font-display: 'Space Grotesk', 'Arial Narrow', Arial, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --shell: 1100px;
  --measure: 68ch;
  --pad-x: 18px;
  --tap: 44px;
}

@media (min-width: 700px)  { :root { --pad-x: 32px; } }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--text-on-ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, canvas, svg, video { max-width: 100%; }
img { height: auto; }

a { color: inherit; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  background: var(--amber);
  color: #1a1204;
  padding: 12px 18px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { left: 8px; top: 8px; }

/* ---------------- Sprocket rails (desktop flourish only) ------------- */

.filmrail {
  position: fixed;
  top: 0; bottom: 0;
  width: 22px;
  background-image: repeating-linear-gradient(
    to bottom,
    var(--rule-soft) 0px, var(--rule-soft) 10px,
    transparent 10px, transparent 26px
  );
  background-position: center;
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
}
.filmrail.left { left: 0; }
.filmrail.right { right: 0; }
@media (max-width: 1023px) { .filmrail { display: none; } }

/* ---------------- Header / nav ---------------- */

header.site {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--rule-soft);
  padding: 14px var(--pad-x);
  background: var(--ink);
}

.header-inner {
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--text-on-ink);
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 78%;
}
.brand .brand-mark {
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border: 1px solid var(--amber-dim);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
  flex: none;
}

/* CSS-only nav toggle — no JS dependency */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  margin: -8px -8px -8px 0;
  cursor: pointer;
  color: var(--text-on-ink);
  border-radius: 4px;
}
.nav-btn span,
.nav-btn span::before,
.nav-btn span::after {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}
.nav-btn span { position: relative; }
.nav-btn span::before,
.nav-btn span::after { content: ''; position: absolute; left: 0; }
.nav-btn span::before { top: -6px; }
.nav-btn span::after  { top: 6px; }
.nav-toggle:focus-visible + .nav-btn { outline: 2px solid var(--amber); outline-offset: 2px; }

nav.site-nav {
  display: none;
  width: 100%;
  flex-direction: column;
  padding-top: 8px;
  border-top: 1px solid var(--rule-soft);
  margin-top: 6px;
}
.nav-toggle:checked ~ nav.site-nav { display: flex; }

nav.site-nav a {
  text-decoration: none;
  color: var(--text-on-ink-dim);
  font-size: 0.95rem;
  padding: 12px 2px;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--rule-soft);
}
nav.site-nav a:last-child { border-bottom: none; }
nav.site-nav a:hover,
nav.site-nav a[aria-current="page"] { color: var(--amber); }

@media (min-width: 860px) {
  .nav-btn { display: none; }
  .brand { max-width: none; font-size: 1.15rem; }
  nav.site-nav {
    display: flex;
    flex-direction: row;
    width: auto;
    gap: 22px;
    padding-top: 0;
    margin-top: 0;
    border-top: none;
    font-size: 0.9rem;
  }
  nav.site-nav a {
    padding: 4px 0 3px;
    min-height: 0;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
  }
  nav.site-nav a:hover,
  nav.site-nav a[aria-current="page"] { border-color: var(--amber-dim); }
}

/* ---------------- Layout shells ---------------- */

main {
  position: relative;
  z-index: 1;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--pad-x) 72px;
}

.lede { max-width: var(--measure); margin: 36px 0 26px; }
@media (min-width: 700px) { .lede { margin: 52px 0 34px; } }

.lede h1 {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 5.2vw, 2.6rem);
  line-height: 1.14;
  margin: 0 0 14px;
  font-weight: 700;
  overflow-wrap: break-word;
}
.lede p {
  color: var(--text-on-ink-dim);
  font-size: clamp(0.98rem, 2.6vw, 1.08rem);
  margin: 0;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--amber);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

/* ---------------- Paper surfaces ---------------- */

.tool-panel,
.content-block {
  background: var(--paper);
  color: var(--text-on-paper);
  border-radius: 6px;
  padding: 20px;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.6);
}
@media (min-width: 700px) {
  .tool-panel  { padding: 34px; }
  .content-block { padding: 38px; }
}

/* ---------------- Form controls ---------------- */

.tool-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
}

.url-input,
.num-input,
select.ctl {
  flex: 1 1 100%;
  min-width: 0;
  padding: 13px 14px;
  min-height: var(--tap);
  border: 1.5px solid var(--paper-dim);
  border-radius: 4px;
  background: #fff;
  color: var(--text-on-paper);
  font-family: var(--font-mono);
  font-size: 16px; /* 16px stops iOS Safari zooming on focus */
}
select.ctl { font-family: var(--font-body); }
.num-input { flex: 1 1 120px; }

.url-input:focus,
.num-input:focus,
select.ctl:focus {
  outline: none;
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 3px rgba(226,166,59,0.22);
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  border-radius: 4px;
  padding: 13px 20px;
  min-height: var(--tap);
  cursor: pointer;
  background: var(--ink);
  color: var(--paper);
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 100%;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--rule-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--amber-dim); color: #1a1204; }
.btn.primary:hover { background: var(--amber); }
.btn.ghost {
  background: transparent;
  color: var(--text-on-paper);
  border: 1.5px solid var(--paper-dim);
}
.btn.ghost:hover { background: #fff; }

@media (min-width: 620px) {
  .url-input { flex: 1 1 300px; }
  .btn { flex: 0 0 auto; }
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-on-paper-dim);
  margin-bottom: 5px;
}
.field { flex: 1 1 140px; min-width: 0; }

.tool-note {
  font-size: 0.86rem;
  color: var(--text-on-paper-dim);
  margin-top: 12px;
}

.error-msg {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 3px solid var(--rose);
  background: rgba(201,96,90,0.09);
  color: #7a3733;
  font-size: 0.9rem;
  border-radius: 2px;
  display: none;
}
.error-msg.show { display: block; }

/* Preset chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  font-family: var(--font-body);
  font-size: 0.83rem;
  padding: 9px 12px;
  min-height: 38px;
  border: 1.5px solid var(--paper-dim);
  background: #fff;
  color: var(--text-on-paper-dim);
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover, .chip[aria-pressed="true"] {
  border-color: var(--amber-dim);
  color: var(--text-on-paper);
}
.chip[aria-pressed="true"] { background: rgba(226,166,59,0.16); }

/* Range */
input[type="range"] { width: 100%; accent-color: var(--amber-dim); min-height: 30px; }

.dropzone {
  display: block;          /* <label> is inline by default; block fixes the border split */
  position: relative;      /* contains the visually-hidden file input */
  border: 2px dashed var(--paper-dim);
  border-radius: 6px;
  padding: 22px 16px;
  text-align: center;
  background: #fff;
  cursor: pointer;
}
.dropzone.drag { border-color: var(--amber-dim); background: rgba(226,166,59,0.1); }
.dropzone p { margin: 6px 0 0; font-size: 0.86rem; color: var(--text-on-paper-dim); }
.dropzone strong { font-size: 0.98rem; }

.size-readout {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-on-paper-dim);
  margin-top: 8px;
}
.size-readout .over { color: #a3352e; font-weight: 600; }
.size-readout .ok   { color: #2f6b3a; font-weight: 600; }

/* ---------------- Results grid ---------------- */

#results { margin-top: 26px; display: none; }
#results.show { display: block; }

.sheet-label {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-on-paper-dim);
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--paper-dim);
  padding-bottom: 9px;
}

.frame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
@media (min-width: 700px) {
  .frame-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
}

.frame {
  border: 1px solid var(--paper-dim);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.frame .thumb-wrap {
  aspect-ratio: 16 / 9;
  background: repeating-conic-gradient(#e5e0d3 0% 25%, #f3efe6 0% 50%) 50% / 18px 18px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.frame .thumb-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.frame .frame-meta { padding: 10px 11px; border-top: 1px solid var(--paper-dim); }
.frame .frame-size {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-on-paper-dim);
  display: block;
}
.frame .frame-dl {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  min-height: 38px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1204;
  background: rgba(226,166,59,0.9);
  border: none;
  border-radius: 3px;
  width: 100%;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-body);
}
.frame .frame-dl:hover { background: var(--amber); }

/* ---------------- Long-form article ---------------- */

.article { margin-top: 18px; }
.article > * { max-width: var(--measure); }
.article h2 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3.6vw, 1.55rem);
  line-height: 1.25;
  margin: 34px 0 12px;
  color: var(--text-on-paper);
}
.article h2:first-child { margin-top: 0; }
.article h3 {
  font-family: var(--font-display);
  font-size: 1.06rem;
  margin: 24px 0 8px;
}
.article p,
.article li { color: var(--text-on-paper-dim); font-size: 1rem; }
.article p { margin: 0 0 15px; }
.article ul, .article ol { padding-left: 20px; margin: 0 0 15px; }
.article li { margin-bottom: 7px; }
.article a { color: var(--amber-dim); text-decoration: underline; text-underline-offset: 2px; }
.article a:hover { color: var(--rose); }
.article strong { color: var(--text-on-paper); }

.table-scroll { overflow-x: auto; margin: 0 0 18px; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.specs {
  border-collapse: collapse;
  width: 100%;
  min-width: 460px;
  font-size: 0.9rem;
}
table.specs th, table.specs td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--paper-dim);
  color: var(--text-on-paper-dim);
}
table.specs th { color: var(--text-on-paper); font-weight: 600; white-space: nowrap; }
table.specs td:first-child { font-family: var(--font-mono); font-size: 0.84rem; white-space: nowrap; }

/* ---------------- FAQ ---------------- */

.faq { margin-top: 10px; max-width: var(--measure); }
.faq details {
  border-bottom: 1px solid var(--paper-dim);
  padding: 2px 0;
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 15px 34px 15px 0;
  position: relative;
  font-weight: 600;
  font-size: 0.99rem;
  color: var(--text-on-paper);
  min-height: var(--tap);
  display: flex;
  align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+';
  position: absolute;
  right: 4px;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  color: var(--amber-dim);
  line-height: 1;
}
.faq details[open] summary::after { content: '\2212'; }
.faq details p {
  margin: 0 0 15px;
  color: var(--text-on-paper-dim);
  font-size: 0.96rem;
}

/* ---------------- Ad slots ---------------- */

.ad-slot {
  margin: 26px auto;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
}
.ad-slot::before {
  content: 'Advertisement';
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--text-on-ink-dim);
  margin-bottom: 6px;
  opacity: 0.75;
}
.ad-slot.on-paper::before { color: var(--text-on-paper-dim); }
/* Reserved height keeps ads from shifting layout (protects Core Web Vitals CLS) */
.ad-slot ins.ad-unit { display: block; min-height: 100px; }
@media (min-width: 800px) { .ad-slot ins.ad-unit { min-height: 280px; } }
/* Until the AdSense <ins> is uncommented the slot holds an empty placeholder;
   collapse the whole block so visitors never see a labelled blank gap. */
.ad-slot:has(> .ad-placeholder) { display: none; }

/* ---------------- Post list ---------------- */

.post-list { display: flex; flex-direction: column; }
.post-item { padding: 20px 0; border-bottom: 1px solid var(--paper-dim); }
.post-item:first-child { padding-top: 0; }
.post-item:last-child { border-bottom: none; }
.post-item h3 { font-family: var(--font-display); margin: 0 0 6px; font-size: 1.08rem; }
.post-item a { text-decoration: none; color: var(--text-on-paper); }
.post-item a:hover { color: var(--amber-dim); }
.post-item p { margin: 0; font-size: 0.93rem; color: var(--text-on-paper-dim); }
.post-date {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--amber-dim);
  display: block;
  margin-bottom: 7px;
}

/* ---------------- Breadcrumb ---------------- */

.crumbs {
  font-size: 0.82rem;
  color: var(--text-on-ink-dim);
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.crumbs li::after { content: '/'; margin-left: 6px; opacity: 0.5; }
.crumbs li:last-child::after { content: ''; }
.crumbs a { color: var(--text-on-ink-dim); text-decoration: none; }
.crumbs a:hover { color: var(--amber); }

/* ---------------- Cross-link card ---------------- */

.crosslink {
  border: 1px solid var(--paper-dim);
  border-left: 3px solid var(--amber-dim);
  border-radius: 4px;
  padding: 16px 18px;
  margin: 24px 0;
  background: #fff;
  max-width: var(--measure);
}
.crosslink p { margin: 0; font-size: 0.93rem; color: var(--text-on-paper-dim); }
.crosslink strong { display: block; margin-bottom: 4px; color: var(--text-on-paper); font-size: 1rem; }

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

footer.site {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--rule-soft);
  padding: 26px var(--pad-x) 34px;
  font-size: 0.85rem;
  color: var(--text-on-ink-dim);
}
.footer-inner {
  max-width: var(--shell);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.footer-nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer-nav a {
  color: var(--text-on-ink-dim);
  text-decoration: none;
  padding: 6px 0;
  display: inline-block;
}
.footer-nav a:hover { color: var(--amber); text-decoration: underline; text-underline-offset: 3px; }
.footer-note { margin: 0; max-width: var(--measure); opacity: 0.85; font-size: 0.8rem; }
@media (min-width: 800px) {
  .footer-inner { flex-direction: row; justify-content: space-between; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* ---------------- Utility ---------------- */

.visually-hidden {
  position: absolute !important;
  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;
}

.article code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: rgba(23,24,28,0.07);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-on-paper);
  overflow-wrap: break-word;
}
.article em { font-style: italic; }
.faq code { font-family: var(--font-mono); font-size: 0.87em; background: rgba(23,24,28,0.07); padding: 1px 5px; border-radius: 3px; }
.faq a { color: var(--amber-dim); text-decoration: underline; text-underline-offset: 2px; }
.faq h2 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3.6vw, 1.55rem);
  margin: 0 0 6px;
  color: var(--text-on-paper);
}
