/* ==========================================================================
   TOOLSTOPIA — shared.css
   Design system "The Digital Workshop": dark-ink foundation, chartreuse
   accent, blueprint linework, spec-sheet typography. Tokens + reset +
   primitives (buttons, forms, badges, modal, toast, skeletons).
   ========================================================================== */

/* ------------------------------- tokens ---------------------------------- */
:root {
  --ink: #101411;
  --surface: #171d19;
  --elevated: #202923;
  --border: #344238;
  --border-soft: #26302a;
  --chartreuse: #d6f36a;
  --chartreuse-ink: #1a2005;
  --mineral: #91b7a2;
  --parchment: #f0ede3;
  --muted: #a9b3aa;
  --coral: #ff8066;
  --white: #ffffff;

  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-card: 6px 6px 0 0 rgba(52, 66, 56, 0.55);
  --shadow-card-hover: 8px 8px 0 0 rgba(214, 243, 106, 0.28);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.5);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px; --space-9: 96px;

  --container: 1240px;
  --header-h: 72px;

  --t-fast: 160ms cubic-bezier(.4, 0, .2, 1);
  --t-med: 280ms cubic-bezier(.4, 0, .2, 1);
  --focus-ring: 0 0 0 2px var(--ink), 0 0 0 4px var(--chartreuse);
}

/* light "daylight workshop" theme */
[data-theme="light"] {
  --ink: #f0ede3;
  --surface: #faf8f0;
  --elevated: #ffffff;
  --border: #c9c4b2;
  --border-soft: #ddd8c8;
  --chartreuse: #93b425;
  --chartreuse-ink: #ffffff;
  --mineral: #47705b;
  --parchment: #17201a;
  --muted: #5c665e;
  --coral: #c94f38;
  --white: #101411;
  --shadow-card: 6px 6px 0 0 rgba(150, 145, 125, 0.35);
}

/* -------------------------------- reset ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

/* Author display rules must never resurrect hidden elements */
[hidden] { display: none !important; }

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

body {
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body.nav-locked { overflow: hidden; }

img, svg, video { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; text-decoration: none; }
mark { background: var(--chartreuse); color: var(--chartreuse-ink); border-radius: 3px; padding: 0 2px; }

::selection { background: var(--chartreuse); color: var(--chartreuse-ink); }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--mineral); }

/* ------------------------------ typography -------------------------------- */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }

.display-1 {
  font-family: var(--font-display);
  font-weight: 480;
  font-size: clamp(2.5rem, 5.6vw, 4.35rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.display-2 {
  font-family: var(--font-display);
  font-weight: 480;
  font-size: clamp(1.7rem, 3.2vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.display-3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.25rem, 2vw, 1.55rem);
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--mineral);
}

.lead { color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.15rem); max-width: 56ch; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ------------------------------- layout ----------------------------------- */
.container { max-width: var(--container); margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }

.section { padding-block: clamp(40px, 7vw, 88px); }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap;
}
.section-head .eyebrow { display: block; margin-bottom: var(--space-2); }
.section-link { font-family: var(--font-mono); font-size: 0.82rem; color: var(--mineral); }
.section-link:hover { color: var(--chartreuse); }

/* blueprint divider between major sections */
.blueprint-rule {
  border: none; height: 0;
  border-top: 1px dashed var(--border);
  position: relative;
  margin-inline: clamp(16px, 4vw, 32px);
}

/* ------------------------------- buttons ---------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font-ui); font-weight: 600; font-size: 0.95rem;
  padding: 12px 22px; border-radius: 999px; border: 2px solid transparent;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  user-select: none; text-align: center;
}
.btn:active { transform: translateY(2px) scale(0.99); }
.btn[disabled], .btn.is-busy { opacity: 0.55; pointer-events: none; }

.btn-primary { background: var(--chartreuse); color: var(--chartreuse-ink); box-shadow: 4px 4px 0 0 rgba(52, 66, 56, 0.8); }
.btn-primary:hover { box-shadow: 6px 6px 0 0 rgba(214, 243, 106, 0.35); transform: translate(-1px, -1px); }

.btn-ghost { border-color: var(--border); color: var(--parchment); background: transparent; }
.btn-ghost:hover { border-color: var(--mineral); color: var(--chartreuse); }

.btn-danger { background: var(--coral); color: #2b0d05; }
.btn-danger:hover { filter: brightness(1.08); }

.btn-icon {
  width: 42px; height: 42px; padding: 0; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--border); color: var(--muted); background: transparent;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.btn-icon:hover { color: var(--chartreuse); border-color: var(--mineral); }
.btn-icon svg { width: 18px; height: 18px; }

/* -------------------------------- badges ---------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.66rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  padding: 4px 10px; border-radius: 4px;
}
.badge-new { background: var(--coral); color: #2b0d05; }
.badge-featured { background: var(--chartreuse); color: var(--chartreuse-ink); }
.badge-draft { background: var(--elevated); color: var(--muted); border: 1px solid var(--border); }
.badge-published { background: rgba(145, 183, 162, 0.16); color: var(--mineral); border: 1px solid var(--mineral); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.78rem;
  padding: 6px 14px; border-radius: 999px;
  border: 1.5px solid var(--border); color: var(--muted);
  background: transparent; cursor: pointer;
  transition: all var(--t-fast);
}
.chip:hover, .chip.is-active { border-color: var(--chartreuse); color: var(--chartreuse); background: rgba(214, 243, 106, 0.06); }

/* -------------------------------- forms ----------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-weight: 600; font-size: 0.9rem; }
.field .hint { font-size: 0.78rem; color: var(--muted); }
.field .counter { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); text-align: right; }

.input, .select, .textarea {
  width: 100%; background: var(--surface); color: var(--parchment);
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 14px; transition: border-color var(--t-fast), background var(--t-fast);
}
.textarea { resize: vertical; min-height: 96px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--chartreuse); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.7; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }

.field-error { font-size: 0.8rem; color: var(--coral); display: none; }
.field.has-error .input, .field.has-error .textarea, .field.has-error .select { border-color: var(--coral); }
.field.has-error .field-error { display: block; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 44px; height: 24px; border-radius: 999px; background: var(--elevated);
  border: 2px solid var(--border); position: relative; transition: background var(--t-fast), border-color var(--t-fast);
  flex-shrink: 0;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted); transition: transform var(--t-fast), background var(--t-fast);
}
.switch input:checked + .track { background: var(--chartreuse); border-color: var(--chartreuse); }
.switch input:checked + .track::after { transform: translateX(20px); background: var(--chartreuse-ink); }
.switch input:focus-visible + .track { box-shadow: var(--focus-ring); }

/* ------------------------------ modal / toast ------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(6, 9, 7, 0.72); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: var(--space-4);
  opacity: 0; transition: opacity var(--t-med);
}
.modal-backdrop.is-open { opacity: 1; }

.modal {
  background: var(--elevated); border: 2px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-modal);
  max-width: 460px; width: 100%; padding: var(--space-6);
  transform: translateY(10px) scale(0.98); transition: transform var(--t-med);
}
.modal-backdrop.is-open .modal { transform: none; }
.modal-title { font-family: var(--font-display); font-size: 1.3rem; margin-bottom: var(--space-3); }
.modal-message { color: var(--muted); margin-bottom: var(--space-5); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-3); flex-wrap: wrap; }

.toast-stack {
  position: fixed; bottom: var(--space-4); right: var(--space-4); z-index: 300;
  display: flex; flex-direction: column; gap: var(--space-2); max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--elevated); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  font-size: 0.9rem; box-shadow: var(--shadow-modal);
  opacity: 0; transform: translateX(12px); transition: opacity var(--t-med), transform var(--t-med);
}
.toast.is-in { opacity: 1; transform: none; }
.toast-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; background: var(--mineral); }
.toast-success .toast-dot { background: var(--chartreuse); }
.toast-error .toast-dot { background: var(--coral); }
.toast-error { border-color: var(--coral); }

/* ------------------------------- skeletons -------------------------------- */
.skeleton {
  position: relative; overflow: hidden; background: var(--surface);
  border-radius: var(--radius-sm);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(169, 179, 170, 0.09), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ------------------------------- utilities -------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.stack { display: flex; flex-direction: column; }
.gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }

/* ---------------------------- reduced motion ------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
