/* ========================================================
   Pinchr — shared editorial / print-zine design system
   Fraunces serif + JetBrains Mono + fluorescent orange
   ======================================================== */

:root {
  --ink: #18181b;
  --paper: #f4f1ea;
  --paper-dark: #ebe6dc;
  --rule: #18181b;
  --accent: #ff4a1c;
  --accent-soft: #ffe4da;
  --muted: #6b6b6b;
  --ok: #0f7a3d;
  --err: #c6361b;
  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-display);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(0,0,0,0.015) 0%, transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(0,0,0,0.015) 0%, transparent 50%);
}
a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input[type="file"] { display: none; }

/* -------- Masthead -------- */
.masthead {
  border-bottom: 2px solid var(--ink);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  gap: 24px;
  flex-wrap: wrap;
  min-height: 50px;
}
.masthead .edition {
  text-transform: uppercase;
  text-decoration: none;
  font-weight: 500;
  max-width: 100%;
}
@media (min-width: 900px) {
  .masthead .edition { white-space: nowrap; }
}
.masthead .edition:hover { color: var(--accent); }
.masthead .date {
  color: var(--muted);
  white-space: nowrap;
  min-width: 160px;
  text-align: right;
}
@media (max-width: 600px) {
  .masthead .date { display: none; }
}

/* -------- Section nav -------- */
.sections {
  border-bottom: 1px solid var(--ink);
  padding: 10px 24px;
  display: flex;
  gap: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sections::-webkit-scrollbar { display: none; }
.sections a {
  padding: 6px 14px;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
  border-right: 1px solid rgba(0,0,0,0.12);
}
.sections a:first-child { padding-left: 0; }
.sections a:last-child { border-right: none; }
.sections a:hover { color: var(--ink); }
.sections a.current { color: var(--accent); font-weight: 500; }

main { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* -------- Hero -------- */
.hero { padding: 64px 0 48px; border-bottom: 1px solid var(--ink); position: relative; }
.kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(48px, 9vw, 120px);
  line-height: 0.92;
  letter-spacing: -0.03em;
  font-variation-settings: "opsz" 144;
}
h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  font-variation-settings: "opsz" 144;
}
.lede {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.5;
  max-width: 640px;
  margin-top: 28px;
  color: #333;
}
.lede strong { font-weight: 500; background: var(--accent-soft); padding: 1px 4px; }

/* -------- Tool panel -------- */
.tool {
  margin: 48px 0;
  border: 2px solid var(--ink);
  background: #fff;
  position: relative;
}
.tool::before {
  content: "";
  position: absolute;
  top: -10px; left: -10px;
  width: 18px; height: 18px;
  border-top: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
}
.tool::after {
  content: "";
  position: absolute;
  bottom: -10px; right: -10px;
  width: 18px; height: 18px;
  border-bottom: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
}

.tool-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--paper-dark);
}
.tool-header .status::before {
  content: "●";
  color: var(--ok);
  margin-right: 6px;
}
.tool-header .status.working::before { color: var(--accent); animation: pulse 1s ease-in-out infinite; }
.tool-header .status.error::before { color: var(--err); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Drop zone */
.dropzone {
  padding: 64px 24px;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  border: 2px dashed transparent;
  margin: 16px;
}
.dropzone:hover, .dropzone.drag-over {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.dropzone .dz-icon {
  font-size: 56px;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 12px;
}
.dropzone .dz-primary {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
}
.dropzone .dz-primary u { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.dropzone .dz-secondary {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  letter-spacing: 0.04em;
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--ink);
  background: var(--paper-dark);
}
.controls.two { grid-template-columns: 1fr 1fr; }
.controls.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
  .controls, .controls.two, .controls.four { grid-template-columns: 1fr; }
}
.control {
  padding: 14px 18px;
  border-right: 1px solid rgba(0,0,0,0.15);
}
.control:last-child { border-right: none; }
@media (max-width: 720px) { .control { border-right: none; border-bottom: 1px solid rgba(0,0,0,0.15); } }
.control label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.control .value {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18px;
}
.control input[type="range"] { width: 100%; accent-color: var(--accent); }
.control select,
.control input[type="number"],
.control input[type="text"],
.control input[type="url"],
.control textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--ink);
  border-radius: 0;
}
.control textarea { resize: vertical; min-height: 48px; }
.control .inline {
  display: flex;
  gap: 8px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
}
.control .inline input[type="number"] { width: 88px; }
.control .checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 6px;
  cursor: pointer;
}
.control .checkbox input { accent-color: var(--accent); }

/* Results list */
.results {
  border-top: 1px solid var(--ink);
  max-height: 600px;
  overflow-y: auto;
}
.results:empty { display: none; }
.result-row {
  display: grid;
  grid-template-columns: 64px 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 600px) {
  .result-row {
    grid-template-columns: 48px 1fr auto;
    grid-template-areas:
      "thumb info saved"
      "thumb info btn";
    row-gap: 6px;
  }
  .result-row > .result-thumb { grid-area: thumb; }
  .result-row > .result-info  { grid-area: info; }
  .result-row > .result-saved { grid-area: saved; text-align: right; }
  .result-row > .download-btn { grid-area: btn; justify-self: end; }
}
.result-row:last-child { border-bottom: none; }
.result-thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border: 1px solid var(--ink);
  background: var(--paper-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
}
@media (max-width: 600px) { .result-thumb { width: 48px; height: 48px; } }
.result-info { min-width: 0; }
.result-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.result-sizes {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.result-sizes .arrow { color: var(--ink); margin: 0 4px; }
.result-sizes .new { color: var(--ink); font-weight: 500; }
.result-sizes.err { color: var(--err); }
.result-saved {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ok);
  white-space: nowrap;
}
.result-saved.zero { color: var(--muted); }
.result-saved .spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid var(--paper-dark);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.download-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  transition: background 0.15s, color 0.15s;
}
.download-btn:hover { background: var(--accent); border-color: var(--accent); }
.download-btn.processing { background: var(--paper-dark); color: var(--muted); cursor: wait; border-color: transparent; }
.download-btn:disabled { cursor: not-allowed; }

.results-actions {
  padding: 16px 24px;
  border-top: 1px solid var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--paper-dark);
  font-family: var(--font-mono);
  font-size: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.results-actions:empty { display: none; }
.results-actions .summary { color: var(--muted); }
.results-actions .summary strong { color: var(--ok); font-weight: 500; }
.btn-primary {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  border: 1px solid var(--accent);
}
.btn-primary:hover { background: var(--ink); border-color: var(--ink); }
.btn-primary:disabled { background: var(--paper-dark); color: var(--muted); border-color: var(--paper-dark); cursor: wait; }
.btn-ghost {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 14px;
  color: var(--muted);
  border: 1px solid transparent;
}
.btn-ghost:hover { color: var(--ink); }

/* -------- Feature stripe -------- */
.stripe {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  margin: 32px 0;
}
@media (max-width: 720px) { .stripe { grid-template-columns: 1fr; } }
.stripe > div {
  padding: 28px 24px;
  border-right: 1px solid var(--ink);
}
.stripe > div:last-child { border-right: none; }
@media (max-width: 720px) {
  .stripe > div { border-right: none; border-bottom: 1px solid var(--ink); }
  .stripe > div:last-child { border-bottom: none; }
}
.stripe h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
  color: var(--accent);
}
.stripe p {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.45;
}

/* -------- Editorial -------- */
article.editorial {
  padding: 48px 0 32px;
  border-top: 2px solid var(--ink);
  max-width: 720px;
}
article.editorial h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  margin: 40px 0 16px;
}
article.editorial h2:first-of-type { margin-top: 0; }
article.editorial h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: 22px;
  margin: 28px 0 10px;
}
article.editorial p {
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 16px;
  color: #2a2a2a;
}
article.editorial p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 68px;
  float: left;
  line-height: 0.85;
  margin: 6px 8px 0 0;
  color: var(--accent);
}
article.editorial ul { margin: 12px 0 20px 24px; font-size: 18px; line-height: 1.6; }
article.editorial li { margin-bottom: 6px; }
article.editorial details {
  border-top: 1px solid var(--ink);
  padding: 18px 0;
}
article.editorial details[open] { padding-bottom: 22px; }
article.editorial summary {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
article.editorial summary::-webkit-details-marker { display: none; }
article.editorial summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--accent);
  transition: transform 0.2s;
}
article.editorial details[open] summary::after { transform: rotate(45deg); }
article.editorial details p { margin-top: 12px; font-size: 16px; }

/* -------- Other tools -------- */
.other-tools {
  margin: 48px 0 8px;
  border-top: 2px solid var(--ink);
  padding-top: 28px;
}
.other-tools .label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}
.other-tools .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0;
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}
.other-tools .card {
  padding: 20px 20px;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  text-decoration: none;
  display: block;
  background: var(--paper);
  transition: background 0.15s;
}
.other-tools .card:hover { background: var(--accent-soft); }
.other-tools .card .t {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}
.other-tools .card .t em { font-style: italic; color: var(--accent); }
.other-tools .card .d {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* -------- Footer -------- */
footer {
  border-top: 2px solid var(--ink);
  padding: 32px 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  max-width: 1180px;
  margin: 32px auto 0;
}
footer nav { display: flex; flex-wrap: wrap; gap: 18px; }
footer nav a { color: var(--muted); }
footer nav a:hover { color: var(--accent); }

/* -------- Breadcrumb -------- */
.breadcrumb {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 24px 0;
  max-width: 1180px;
  margin: 0 auto;
}
.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 0;
}
.breadcrumb li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb li:not(:last-child)::after {
  content: "/";
  color: var(--muted);
  opacity: 0.6;
}
.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb li[aria-current="page"] { color: var(--ink); }

/* -------- Toast -------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 20px;
  z-index: 100;
  transition: transform 0.3s ease-out;
  max-width: 90vw;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ========================================================
   Mobile refinements
   Applied on touch-primary and narrow viewports
   ======================================================== */

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

body {
  -webkit-tap-highlight-color: rgba(255, 74, 28, 0.15);
}

/* Keyboard focus styles — visible without being ugly */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* iOS auto-zooms any input under 16px on focus. Force 16px on mobile globally. */
@media (max-width: 720px) {
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  input[type="url"],
  input[type="search"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px;
  }
}

/* Touch-friendly nav tabs — ensure ~44px tap area on phones */
@media (max-width: 720px) {
  .sections a {
    padding: 10px 14px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .download-btn {
    padding: 11px 14px;
    min-height: 40px;
  }
  .btn-primary,
  .btn-ghost {
    padding: 12px 16px;
    min-height: 44px;
  }
}

/* Drop zone is too spacious on phones — tighten */
@media (max-width: 600px) {
  .dropzone { padding: 40px 16px; margin: 12px; }
  .dropzone .dz-icon { font-size: 44px; margin-bottom: 8px; }
  .dropzone .dz-primary { font-size: 22px; }
  .tool { margin: 32px 0; }
}

/* -------- Mobile hamburger menu -------- */
/* Button hidden on desktop; nav is always visible horizontally */
.nav-toggle { display: none; }

@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-bottom: 1px solid var(--ink);
    background: var(--paper);
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink);
    cursor: pointer;
    min-height: 48px;
  }
  .nav-toggle .bars {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    width: 18px;
    margin-right: 10px;
  }
  .nav-toggle .bars::before,
  .nav-toggle .bars::after,
  .nav-toggle .bars span {
    content: "";
    display: block;
    height: 2px;
    background: var(--ink);
  }
  .nav-toggle::after {
    content: "▾";
    color: var(--accent);
    font-size: 14px;
    transition: transform 0.2s;
  }
  .nav-toggle[aria-expanded="true"]::after {
    transform: rotate(180deg);
  }
  .nav-toggle[aria-expanded="true"] {
    background: var(--paper-dark);
  }

  /* Mobile: nav hidden until .open, then reveals as vertical dropdown */
  nav.sections {
    display: none;
    flex-direction: column;
    padding: 0;
    overflow: visible;
    border-bottom: 1px solid var(--ink);
  }
  nav.sections.open {
    display: flex;
    animation: slideDown 0.18s ease-out;
  }
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }
  nav.sections a {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    min-height: 48px;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--ink);
  }
  nav.sections a:first-child { padding-left: 24px; }
  nav.sections a:last-child { border-bottom: none; }
  nav.sections a:hover { background: var(--paper-dark); color: var(--accent); }
  nav.sections a.current {
    color: var(--accent);
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
  }
}

/* Hero padding tighter on phones */
@media (max-width: 600px) {
  .hero { padding: 40px 0 32px; }
  .lede { margin-top: 20px; }
  article.editorial { padding: 32px 0 24px; }
  article.editorial p:first-of-type::first-letter {
    font-size: 48px;
    margin: 4px 6px 0 0;
  }
}

/* Footer — stack contents instead of squeezing */
@media (max-width: 600px) {
  footer { flex-direction: column; gap: 16px; padding: 24px; }
  footer nav { gap: 14px; }
}
