/* ============================================================
   FILE:    assets/css/softofu.css
   PURPOSE: ALL site styling — design tokens + every component.
   INPUT:   none (static stylesheet).
   OUTPUT:  the soft, calm "tofu" look across the whole site.
   HOW:     design tokens live at the very top; every colour and
            size is derived from them — never hardcode a hex below.
   ============================================================ */

/* ------------------------------------------------------------
   1. DESIGN TOKENS  (CLAUDE.md §6 — the single source of truth)
   ------------------------------------------------------------ */
:root {
  /* Colour — derived from tofu + soy */
  --bg:        #FAF8F3;   /* soft warm tofu cream (page background, not harsh white) */
  --surface:   #FFFFFF;   /* tofu-block cards sit slightly brighter than the page */
  --ink:       #2B2A26;   /* main text — soft near-black, never pure #000 */
  --ink-soft:  #6B6862;   /* secondary text, captions */
  --accent:    #7FB069;   /* soy / edamame green — primary buttons, links (ONE accent only) */
  --accent-press: #6C9A58;/* pressed/active state of the accent */
  --line:      #ECE8DF;   /* hairline dividers, card borders */
  --warn:      #D98A4E;   /* gentle warning/error tone (warm, not alarming red) */

  /* Shape — soft & rounded everywhere */
  --radius-card: 16px;    /* the tofu-block squircle radius */
  --radius-ctrl: 12px;    /* inputs, buttons */
  --shadow:    0 4px 20px rgba(43,42,38,0.06);  /* soft, diffused — never harsh */

  /* Type — friendly rounded sans, large for all ages */
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-base: 17px;        /* large base — older eyes matter */
  --fs-h1: 2rem;
  --space: 8px;           /* spacing unit; use multiples (space*2, space*3 ...) */

  /* Derived helpers (kept here so tools never invent their own) */
  --accent-soft: rgba(127,176,105,0.14); /* tinted accent fills */
  --warn-soft:   rgba(217,138,78,0.14);
  --maxw: 1080px;         /* page content width */
}

/* ------------------------------------------------------------
   2. RESET & BASE
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3 { line-height: 1.25; font-weight: 700; margin: 0 0 calc(var(--space) * 2); }
h1 { font-size: var(--fs-h1); letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; }
p { margin: 0 0 calc(var(--space) * 2); }
a { color: var(--accent-press); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Page width container, reused everywhere. */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: calc(var(--space) * 3); }

/* Hairline divider used to separate frame sections. */
.rule { border: 0; border-top: 1px solid var(--line); margin: calc(var(--space) * 4) 0; }

/* Accessibility helpers. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: 8px 14px;
  border-radius: var(--radius-ctrl); box-shadow: var(--shadow);
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

/* Visible keyboard focus rings everywhere (quality floor). */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------
   3. HEADER / NAV / SEARCH
   ------------------------------------------------------------ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.site-header__inner {
  display: flex; align-items: center; gap: calc(var(--space) * 2);
  min-height: 64px; padding-block: calc(var(--space) * 1.5);
}
.site-logo { flex: 0 0 auto; }
.site-logo img { height: 38px; width: auto; }

.primary-nav { margin-left: auto; }
.primary-nav__list {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: calc(var(--space) * 1);
}
.primary-nav__list a {
  display: block; padding: 8px 12px; border-radius: var(--radius-ctrl);
  color: var(--ink); font-weight: 600;
}
.primary-nav__list a:hover { background: var(--accent-soft); text-decoration: none; }

.site-search { flex: 0 0 auto; }
.site-search__input {
  font: inherit; font-size: 0.95rem;
  padding: 10px 14px; min-height: 44px; width: 200px;
  border: 1px solid var(--line); border-radius: var(--radius-ctrl);
  background: var(--bg); color: var(--ink);
}
.site-search__input::placeholder { color: var(--ink-soft); }

/* Hamburger — hidden on desktop, shown on mobile via the media query. */
.nav-toggle {
  display: none; margin-left: auto;
  width: 44px; height: 44px; padding: 10px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-ctrl);
  cursor: pointer;
}
.nav-toggle__bar { display: block; height: 2px; background: var(--ink); border-radius: 2px; margin: 4px 0; }

/* ------------------------------------------------------------
   4. MAIN / FOOTER
   ------------------------------------------------------------ */
.site-main { padding-block: calc(var(--space) * 5); min-height: 60vh; }

.site-footer {
  background: var(--surface); border-top: 1px solid var(--line);
  margin-top: calc(var(--space) * 8); padding-block: calc(var(--space) * 5);
}
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; gap: calc(var(--space) * 2); }
.site-footer__logo img { height: 33px; }
.site-footer__nav { display: flex; gap: calc(var(--space) * 2); }
.site-footer__nav a { color: var(--ink); font-weight: 600; }
.site-footer__note { color: var(--ink-soft); margin: 0; flex: 1 1 240px; min-width: 200px; }
.site-footer__copy { color: var(--ink-soft); margin: 0; }

/* ------------------------------------------------------------
   5. TOOL FRAME — breadcrumb, title, work card
   ------------------------------------------------------------ */
.breadcrumb { color: var(--ink-soft); font-size: 0.95rem; margin-bottom: calc(var(--space) * 2); }
.breadcrumb a { color: var(--ink-soft); }
.breadcrumb__sep { margin: 0 8px; }

.tool__title { margin-bottom: var(--space); }
.tool__lead { color: var(--ink-soft); font-size: 1.1rem; max-width: 60ch; }

/* The tofu-block squircle card — the signature shape. */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: calc(var(--space) * 4);
}
.work { display: flex; flex-direction: column; gap: calc(var(--space) * 3); align-items: center; }

/* Mascot — gentle bob while working (respecting reduced motion below). */
.mascot { width: 120px; height: 120px; }
.is-working .mascot, .mascot.is-working { animation: tofu-bob 1.2s ease-in-out infinite; }
@keyframes tofu-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Drop zone — big, obvious, pressable. */
.drop-zone {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: var(--space);
  text-align: center;
  padding: calc(var(--space) * 5) calc(var(--space) * 3);
  border: 2px dashed var(--line); border-radius: var(--radius-card);
  background: var(--bg);
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.drop-zone:hover, .drop-zone:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone__hint { font-size: 1.15rem; font-weight: 600; margin: 0; }
.drop-zone__sub  { color: var(--ink-soft); margin: 0; }

/* Dual drop zones side by side (e.g. Loop Video Maker: image + audio). */
.dual-drop { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--space) * 2); }
.dual-drop .drop-zone { padding: calc(var(--space) * 4) calc(var(--space) * 2); }
.dual-drop__icon { font-size: 2.2rem; line-height: 1; }
@media (max-width: 620px) { .dual-drop { grid-template-columns: 1fr; } }

/* Live-preview editor (e.g. Color & Light): a framed preview image. */
.editor-stage { width: 100%; display: flex; flex-direction: column; gap: calc(var(--space) * 2); align-items: center; }
.editor-preview { max-width: 100%; max-height: 440px; border-radius: var(--radius-ctrl); border: 1px solid var(--line); background: var(--bg); }
/* Large canvas previews scale down to fit (e.g. Safe-Zone Previewer). */
.preview-canvas { max-width: 100%; height: auto; border-radius: var(--radius-ctrl); border: 1px solid var(--line); background: var(--bg); }

/* Metadata report (Metadata Cleaner). */
.meta-report { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-ctrl); overflow: hidden; text-align: left; }
.meta-report__title { font-weight: 700; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
.meta-report__row { display: flex; justify-content: space-between; gap: var(--space); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.meta-report__row:last-child { border-bottom: 0; }
.meta-report__key { color: var(--ink-soft); }
.meta-report__val { font-weight: 600; text-align: right; word-break: break-word; }
.meta-report__row--warn { background: var(--warn-soft); }
.meta-report__row--warn .meta-report__val { color: var(--warn); }

/* Colour palette swatches (Color Palette Extractor). */
.palette { display: flex; flex-wrap: wrap; gap: calc(var(--space) * 1.5); width: 100%; justify-content: center; }
.swatch { width: 120px; border: 1px solid var(--line); border-radius: var(--radius-ctrl); overflow: hidden; background: var(--surface); cursor: pointer; text-align: left; padding: 0; font: inherit; }
.swatch__chip { height: 72px; }
.swatch__info { padding: 8px 10px; }
.swatch__hex { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
.swatch__rgb { color: var(--ink-soft); font-size: 0.78rem; }
.swatch__copied { color: var(--accent-press); font-size: 0.72rem; min-height: 1em; }

/* Stage — the work area for tools that have no file input (e.g. generators). */
.stage {
  width: 100%; display: flex; flex-direction: column; align-items: center;
  gap: calc(var(--space) * 2); text-align: center;
}
.stage__status { color: var(--ink-soft); margin: 0; font-size: 1.05rem; }

/* Options row — tool-specific controls. */
.options-row {
  width: 100%;
  display: flex; flex-wrap: wrap; gap: calc(var(--space) * 3);
  justify-content: center; align-items: flex-end;
}

/* Reusable form controls (shared by all tools — never re-styled per tool). */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 0.9rem; font-weight: 600; color: var(--ink-soft); }
.select, .text-input {
  font: inherit; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-ctrl);
  background: var(--surface); color: var(--ink);
}
.range { width: 180px; accent-color: var(--accent); height: 44px; }

/* Text-tool building blocks (shared by JSON, CSV, Diff, Base64, … ). */
.text-tool { width: 100%; text-align: left; display: flex; flex-direction: column; gap: calc(var(--space) * 2); }
.text-area {
  width: 100%; min-height: 200px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem; line-height: 1.5;
  padding: calc(var(--space) * 1.5); border: 1px solid var(--line);
  border-radius: var(--radius-ctrl); background: var(--bg); color: var(--ink);
}
.code-output {
  width: 100%; max-height: 480px; overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem; line-height: 1.5; white-space: pre;
  padding: calc(var(--space) * 2); margin: 0;
  border: 1px solid var(--line); border-radius: var(--radius-ctrl);
  background: var(--bg); color: var(--ink);
}
.tool-status { color: var(--ink-soft); min-height: 1.2em; margin: 0; }

/* Two text inputs side by side (e.g. Diff Checker). */
.dual-text { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--space) * 2); width: 100%; }
.dual-text > div { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 620px) { .dual-text { grid-template-columns: 1fr; } }

/* Diff output rows (Diff Checker). */
.diff { width: 100%; max-height: 480px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-ctrl); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9rem; }
.diff-row { display: flex; gap: 8px; padding: 2px 10px; white-space: pre-wrap; word-break: break-word; }
.diff-row__sign { flex: 0 0 1ch; color: var(--ink-soft); }
.diff-row--add { background: var(--accent-soft); }
.diff-row--del { background: var(--warn-soft); }
.diff-row--add .diff-row__sign { color: var(--accent-press); }
.diff-row--del .diff-row__sign { color: var(--warn); }

/* Stat cards (e.g. Word Counter). */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: calc(var(--space) * 1.5); width: 100%; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-ctrl); padding: calc(var(--space) * 2); text-align: center; }
.stat__num { font-size: 1.6rem; font-weight: 700; }
.stat__label { color: var(--ink-soft); font-size: 0.85rem; }

/* Segmented control — a row of mutually-exclusive choices (radio inputs). */
.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-ctrl); padding: 4px; gap: 4px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented__btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 0 16px; border-radius: 9px;
  font-weight: 600; color: var(--ink-soft); cursor: pointer; user-select: none;
}
.segmented input:checked + .segmented__btn { background: var(--accent); color: #fff; }
.segmented input:focus-visible + .segmented__btn { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Actions row + buttons. */
.actions { display: flex; flex-wrap: wrap; gap: calc(var(--space) * 1.5); justify-content: center; }
.btn {
  font: inherit; font-weight: 700;
  min-height: 48px; padding: 0 24px;
  border-radius: var(--radius-ctrl); border: 1px solid transparent;
  cursor: pointer; transition: background .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-press); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--accent-soft); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Progress bar — mandatory on every tool. */
.softofu-progress { width: 100%; }
.softofu-progress__track { height: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.softofu-progress__bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .2s ease; }
.softofu-progress__label { text-align: center; color: var(--ink-soft); font-size: 0.95rem; margin: var(--space) 0 0; }

/* Gentle inline error. */
.tool-error {
  width: 100%; text-align: center;
  background: var(--warn-soft); color: var(--ink);
  border: 1px solid var(--warn); border-radius: var(--radius-ctrl);
  padding: calc(var(--space) * 1.5) calc(var(--space) * 2);
}

/* Result / download area. */
.result { width: 100%; display: flex; flex-direction: column; gap: calc(var(--space) * 2); }
.result__bulkbar { display: flex; justify-content: flex-end; }
.result__item {
  display: flex; align-items: center; gap: calc(var(--space) * 2);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-ctrl);
  padding: calc(var(--space) * 1.5);
}
.result__preview { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--surface); flex: 0 0 auto; }
.result__meta { flex: 1 1 auto; min-width: 0; }
.result__name { font-weight: 600; word-break: break-all; }
.result__sub { color: var(--ink-soft); font-size: 0.9rem; }
.result audio { width: 100%; }

/* ------------------------------------------------------------
   6. AD SLOT  (one clean spot; correct when empty)
   ------------------------------------------------------------ */
.ad-slot { width: 100%; }
.ad-slot.is-active { min-height: 90px; text-align: center; }
.ad-slot__label { display: block; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 4px; }
/* When inactive (placeholder ID), the slot adds no visible chrome. */
.ad-slot:not(.is-active) { min-height: 0; }

/* ------------------------------------------------------------
   7. HOW-TO / FAQ / RELATED
   ------------------------------------------------------------ */
.howto__steps { padding-left: 1.2em; }
.howto__steps li { margin-bottom: var(--space); }
.faq__item { border-bottom: 1px solid var(--line); padding: calc(var(--space) * 1.5) 0; }
.faq__q { font-weight: 600; cursor: pointer; }
.faq__a { color: var(--ink-soft); margin: var(--space) 0 0; }
.related__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: calc(var(--space) * 1.5); }
.related__item {
  display: inline-block; padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-weight: 600;
}
.related__item--soon { color: var(--ink-soft); }
.related__item--soon em { font-style: normal; color: var(--accent-press); }

/* ------------------------------------------------------------
   8. HOMEPAGE
   ------------------------------------------------------------ */
.hero { text-align: center; margin-bottom: calc(var(--space) * 6); }
.hero__title { font-size: 2.4rem; margin-bottom: var(--space); }
.hero__lead { color: var(--ink-soft); font-size: 1.2rem; max-width: 56ch; margin-inline: auto; }

.section-title { margin-bottom: calc(var(--space) * 2); }

.category-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: calc(var(--space) * 3); margin-bottom: calc(var(--space) * 7); }
.category-card {
  display: flex; flex-direction: column; gap: var(--space);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow); padding: calc(var(--space) * 3); color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease;
}
.category-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(43,42,38,0.10); text-decoration: none; }
.category-card__icon { font-size: 2rem; }
.category-card__name { font-weight: 700; font-size: 1.2rem; }
.category-card__count { color: var(--ink-soft); font-size: 0.95rem; }

/* "Recently used" strip (filled from localStorage by softofu.js). */
.recent { margin-bottom: calc(var(--space) * 7); }
.recent__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: calc(var(--space) * 1.5); }
.recent__item { display: inline-block; padding: 10px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-weight: 600; }
.recent__empty { color: var(--ink-soft); }

/* Tool cards (popular + directory). */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: calc(var(--space) * 3); }
.tool-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: var(--shadow); padding: calc(var(--space) * 3); color: var(--ink);
  transition: transform .12s ease, box-shadow .12s ease;
}
a.tool-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(43,42,38,0.10); text-decoration: none; }
.tool-card__name { font-weight: 700; font-size: 1.1rem; }
.tool-card__desc { color: var(--ink-soft); font-size: 0.95rem; margin: 0; }
.tool-card--soon { opacity: 0.7; }
.tool-card__soon-tag { align-self: flex-start; font-size: 0.75rem; font-weight: 700; color: var(--accent-press); background: var(--accent-soft); padding: 2px 10px; border-radius: 999px; }

/* ------------------------------------------------------------
   9. DIRECTORY (tools.php) + PROSE (about/privacy)
   ------------------------------------------------------------ */
.directory__group { margin-bottom: calc(var(--space) * 7); scroll-margin-top: 88px; }
.directory__cat-title { display: flex; align-items: baseline; gap: var(--space); }
.directory__cat-title small { color: var(--ink-soft); font-weight: 600; font-size: 0.9rem; }
.directory__empty { color: var(--ink-soft); }

.prose { max-width: 70ch; }
.prose h2 { margin-top: calc(var(--space) * 4); }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: var(--space); }

/* ------------------------------------------------------------
   10. MOBILE STICKY ANCHOR AD
   ------------------------------------------------------------ */
.mobile-anchor {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(43,42,38,0.08);
  padding: var(--space); align-items: center; justify-content: center;
}
.mobile-anchor[hidden] { display: none; }
.mobile-anchor__close {
  position: absolute; top: -14px; right: 10px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
@media (min-width: 721px) { .mobile-anchor { display: none !important; } }

/* ------------------------------------------------------------
   11. RESPONSIVE
   ------------------------------------------------------------ */
@media (max-width: 920px) {
  .category-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  :root { --fs-h1: 1.6rem; }
  .hero__title { font-size: 1.9rem; }
  .nav-toggle { display: block; }
  .primary-nav {
    margin-left: 0; flex-basis: 100%; order: 5;
    display: none;
  }
  .primary-nav.is-open { display: block; }
  .primary-nav__list { flex-direction: column; gap: 4px; }
  .site-search { order: 6; flex-basis: 100%; }
  .site-search__input { width: 100%; }
  .site-header__inner { flex-wrap: wrap; }
  .card { padding: calc(var(--space) * 2.5); }
  .options-row { flex-direction: column; align-items: stretch; }
  .range { width: 100%; }
}

/* ------------------------------------------------------------
   12. REDUCED MOTION (quality floor)
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
