/* ============================================================
   Peakward — shared design system (tokens, reset, components)
   Used by index.html (landing) and app.html (application).
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Space+Grotesk:wght@400;500;700&family=Inter:wght@400;500;600&display=swap');

:root {
  /* palette — light */
  --paper:      #f7f4ee;
  --surface:    #ffffff;
  --surface-2:  #f1ece2;
  --ink:        #17150f;
  --ink-soft:   #4b463c;
  --muted:      #6c665a;
  --line:       #1c1a12;
  --hair:       #d8d0c0;
  --red:        #d42d1e;
  --red-ink:    #b31f12;
  --gold:       #e2951f;
  --green:      #1f6f43;

  --accent:     var(--red);

  /* type */
  --display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;

  --r: 3px; --r-lg: 8px;
  --shadow: 0 1px 2px rgba(20,16,8,.06), 0 6px 20px rgba(20,16,8,.07);
  --shadow-lg: 0 2px 6px rgba(20,16,8,.10), 0 18px 44px rgba(20,16,8,.14);
  --border: 2px solid var(--line);
  --maxw: 1120px;
}

:root[data-theme="dark"],
:root.dark {
  --paper:      #131210;
  --surface:    #1d1b17;
  --surface-2:  #24211c;
  --ink:        #f2ede3;
  --ink-soft:   #cdc6b8;
  --muted:      #9a9284;
  --line:       #3a3529;
  --hair:       #332f26;
  --red:        #f2513f;
  --red-ink:    #f2513f;
  --gold:       #f0ad3d;
  --green:      #48b37a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 2px 8px rgba(0,0,0,.5), 0 22px 50px rgba(0,0,0,.6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:#131210; --surface:#1d1b17; --surface-2:#24211c;
    --ink:#f2ede3; --ink-soft:#cdc6b8; --muted:#9a9284;
    --line:#3a3529; --hair:#332f26; --red:#f2513f; --red-ink:#f2513f;
    --gold:#f0ad3d; --green:#48b37a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.45);
    --shadow-lg: 0 2px 8px rgba(0,0,0,.5), 0 22px 50px rgba(0,0,0,.6);
  }
}

/* reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
/* faint paper grain — tactile, not decorative */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root:not([data-theme="light"]) body::after { mix-blend-mode: screen; opacity: .05; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::after { mix-blend-mode: screen; opacity: .05; } }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--red); color: #fff; }

h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; line-height: 1.08; letter-spacing: -.02em; }

/* ---- shared utilities ---- */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s5); }
.kicker {
  font-family: var(--serif); font-style: italic; font-size: 1.12rem;
  letter-spacing: 0; text-transform: none; color: var(--red);
  display: inline-flex; align-items: center; gap: 12px;
}
.kicker::before { content: ""; width: 26px; height: 2px; background: currentColor; display: inline-block; flex: none; }
.stack > * + * { margin-top: var(--s4); }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---- buttons ---- */
.btn {
  --bg: var(--ink); --fg: var(--paper);
  display: inline-flex; align-items: center; gap: var(--s2);
  background: var(--bg); color: var(--fg);
  font-family: var(--display); font-weight: 700; letter-spacing: .02em;
  padding: 13px 22px; border: 2px solid var(--line); border-radius: var(--r);
  text-decoration: none; transition: transform .1s ease, box-shadow .1s ease, background .12s;
  box-shadow: 4px 4px 0 var(--line);
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--line); }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--line); }
.btn--red { --bg: var(--red); --fg: #fff; border-color: var(--line); }
.btn--ghost { --bg: var(--surface); --fg: var(--ink); box-shadow: 3px 3px 0 var(--line); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 7px 13px; font-size: .82rem; box-shadow: 3px 3px 0 var(--line); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0 var(--hair); }

/* ---- cards ---- */
.card {
  background: var(--surface); border: var(--border); border-radius: var(--r-lg);
  padding: var(--s5); box-shadow: var(--shadow);
}

/* ---- tags ---- */
.tag {
  display: inline-block; font-family: var(--display); font-weight: 700;
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  padding: 4px 8px; border: 2px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.tag.accumulation   { background: #f2dca9; color: #4a3a12; border-color: #4a3a12; }
.tag.intensification { background: #f0bd8f; color: #542c10; border-color: #542c10; }
.tag.realization    { background: var(--red); color: #fff; border-color: var(--red-ink); }
.tag.restoration    { background: #cfe6d7; color: #1c4530; border-color: #1c4530; }
.tag.deload         { background: var(--surface-2); }

/* ---- forms ---- */
.field { margin-bottom: var(--s4); }
label.lbl, .field > label {
  display: block; font-family: var(--display); font-weight: 700;
  font-size: .78rem; letter-spacing: .06em; text-transform: uppercase;
  margin-bottom: var(--s2); color: var(--ink-soft);
}
input[type=number], input[type=text], select, textarea {
  width: 100%; padding: 12px 14px; background: var(--paper);
  border: var(--border); border-radius: var(--r); outline-offset: 2px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--gold); }
textarea { min-height: 96px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.check {
  display: flex; gap: var(--s3); align-items: flex-start;
  font-size: .95rem; line-height: 1.5;
}
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--red); }

/* ---- theme toggle ---- */
.themebtn {
  width: 40px; height: 40px; border: var(--border); border-radius: var(--r);
  display: grid; place-items: center; background: var(--surface); font-size: 1.1rem;
}
.themebtn:hover { background: var(--surface-2); }

/* ---- small shared bits ---- */
.hr { border: 0; border-top: var(--border); margin: var(--s4) 0; }
.of { color: var(--muted); font-weight: 400; }
.unit { font-size: .5em; font-weight: 700; color: var(--muted); margin-left: 3px; letter-spacing: .02em; }
.pill {
  display: inline-block; font-size: .8rem; padding: 4px 10px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--surface);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--display); font-weight: 700; font-size: .78rem;
  padding: 7px 12px; border: 2px solid var(--line); border-radius: 999px;
  background: var(--surface); transition: background .12s, color .12s;
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--ink); color: var(--paper); }
.mini { width: 100%; height: 120px; border: var(--border); border-radius: var(--r); background: var(--paper); }

/* 4-phase campaign bar — recurring motif / section divider */
.rule-bar { display: flex; height: 10px; border: 2px solid var(--line); border-radius: 2px; overflow: hidden; margin: var(--s7) 0; }
.rule-bar i { flex: 1; }
.rule-bar i:nth-child(1) { background: #f2dca9; flex: 4; }
.rule-bar i:nth-child(2) { background: #f0bd8f; flex: 4; }
.rule-bar i:nth-child(3) { background: var(--red); flex: 3; }
.rule-bar i:nth-child(4) { background: #cfe6d7; flex: 1; }

/* ---- reveal: CSS-only. Resting state is fully visible; the animation only
       plays in on load. No JS dependency, degrades to "visible" everywhere. ---- */
.reveal { animation: reveal-in .55s ease; }
@keyframes reveal-in { from { opacity: 0; transform: translateY(20px); } }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
  .btn, .card { transition: none; }
  html { scroll-behavior: auto; }
}
