/*
 * theme.css — Grainfall's design-system values.
 * Mood: organic-earthy — clay, moss, sand and cream. Opens light; a dark set
 * lives under html[data-theme="dark"] for the switch in the bar.
 */

:root {
  --canvas: #f5efe2;
  --surface: #fbf8f2;
  --surface-2: #ece1c8;
  --border: #ddd0b3;
  --border-strong: #c2a97f;
  --ink: #2e2418;
  --muted: #6b6359;
  --accent: #8b5a3c;
  --accent-hover: #764a30;
  --accent-ink: #fbf8f2;
  --accent-text: #8f4d25;
  --accent-strong: #805337;
  --accent-soft: #e9dcc0;
  --accent-border: #c9a97a;
  --success: #5b7444;
  --success-ink: #fbf8f2;
  --success-soft: #e2e7d2;
  --success-strong: #445a30;
  --warning: #a86a2d;
  --warning-ink: #fbf8f2;
  --warning-soft: #f0ddb9;
  --warning-strong: #8a5320;
  --danger: #a4402f;
  --danger-ink: #fbf8f2;
  --danger-soft: #f2d9cd;
  --danger-strong: #832f21;
  --chart-1: #8b5a3c;
  --chart-2: #5b7444;
  --chart-3: #c9a97a;
  --chart-4: #a4402f;
  --chart-5: #6b8a82;
  --chart-6: #cb9038;

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-body: "Work Sans", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Work Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display-weight: 600;
  --display-tracking: -0.01em;
  --eyebrow-tracking: 0.06em;

  --radius-card: 18px;
  --radius-btn: 999px;
  --radius-input: 14px;
  --border-w: 1px;
  --border-strong-w: 1.5px;
  --shadow-card: 0 1px 2px rgba(46, 36, 24, 0.06), 0 10px 26px rgba(46, 36, 24, 0.07);
  --shadow-raised: 0 16px 40px rgba(46, 36, 24, 0.16);
  --shadow-btn: 0 1px 2px rgba(46, 36, 24, 0.1);
  --card-pad: 1.75rem;
  --caps: none;
  --caps-tracking: 0;
  --btn-weight: 600;
  --measure: 62ch;
}

html[data-theme="dark"] {
  --canvas: #201810;
  --surface: #291f15;
  --surface-2: #33271a;
  --border: #473725;
  --border-strong: #6b543a;
  --ink: #f1e6d3;
  --muted: #b3a48c;
  --accent: #c98a5e;
  --accent-hover: #d99c72;
  --accent-ink: #201810;
  --accent-text: #e0a06e;
  --accent-strong: #eab488;
  --accent-soft: #3c2c1c;
  --accent-border: #6d4e32;
  --success: #93b171;
  --success-ink: #17200f;
  --success-soft: #2b3420;
  --success-strong: #aecb8d;
  --warning: #dc9c53;
  --warning-ink: #241a0c;
  --warning-soft: #3a2b17;
  --warning-strong: #edb374;
  --danger: #cf7059;
  --danger-ink: #220f09;
  --danger-soft: #3c2117;
  --danger-strong: #e5947c;
  --chart-1: #c98a5e;
  --chart-2: #93b171;
  --chart-3: #d7bd8d;
  --chart-4: #cf7059;
  --chart-5: #85a69c;
  --chart-6: #dcaa53;
}

/*
 * app.css — Grainfall's own screen: the ground, the hourglass and its sand,
 * the wordmark, the session trail. Everything else is primitives + utilities.
 */

/* ---- Ground ---------------------------------------------------------------
   A soft warm wash behind the whole stage — never a flat, dead canvas. */
body {
  background:
    radial-gradient(ellipse 60% 45% at 50% 8%, color-mix(in srgb, var(--accent-soft) 55%, transparent), transparent 70%),
    radial-gradient(ellipse 70% 50% at 50% 100%, color-mix(in srgb, var(--accent-soft) 40%, transparent), transparent 65%),
    var(--canvas);
}

/* ---- Wordmark --------------------------------------------------------------
   A small poured-sand mark: two triangles of grain pinched at the waist. */
.grain-mark {
  display: inline-block;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 9999px;
  background: conic-gradient(
    from 210deg,
    var(--accent) 0deg,
    var(--accent-strong) 130deg,
    var(--accent) 260deg,
    var(--accent-hover) 360deg
  );
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 12%, transparent);
}

/* ---- The hourglass ---------------------------------------------------------- */
.hourglass-frame {
  display: block;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  animation: hg-enter 720ms cubic-bezier(0.16, 1, 0.3, 1) 80ms both;
}

html.reduced-motion .hourglass-frame {
  opacity: 1;
  transform: none;
  animation: none;
}

@keyframes hg-enter {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

#hourglass {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 18px 30px color-mix(in srgb, var(--ink) 16%, transparent));
}

.hg-wood {
  fill: var(--accent-strong);
}

.hg-glass {
  fill: color-mix(in srgb, var(--surface) 55%, transparent);
}

.hg-edge {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 3;
  stroke-linejoin: round;
}

.hg-sand {
  fill: var(--chart-3);
}

/* Smooths a manual re-pour (duration change); running ticks bypass this so
   the drain reads as continuous rather than eased per-frame. */
.hourglass-frame.is-pouring #sandTop,
.hourglass-frame.is-pouring #sandBottom {
  transition: y 700ms cubic-bezier(0.4, 0, 0.2, 1), height 700ms cubic-bezier(0.4, 0, 0.2, 1);
}

.hg-grains circle {
  fill: var(--accent-strong);
  opacity: 0;
}

.hourglass-frame.is-running .hg-grains circle {
  opacity: 1;
  animation: hg-fall 480ms linear infinite;
}
.hourglass-frame.is-running .hg-grains circle:nth-child(2) { animation-delay: 120ms; }
.hourglass-frame.is-running .hg-grains circle:nth-child(3) { animation-delay: 260ms; }

@keyframes hg-fall {
  0%   { transform: translateY(-4px); opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateY(9px); opacity: 0; }
}

html.reduced-motion .hourglass-frame.is-running .hg-grains circle {
  animation: none;
  opacity: 0.9;
}

/* ---- Session trail ----------------------------------------------------------- */
.trail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  max-width: 20rem;
}

.trail-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--border);
  flex: none;
}

.trail-dot-filled {
  background: var(--accent);
  box-shadow: none;
}

/* ---- Small screens ------------------------------------------------------------
   Never let the frame outgrow a short phone viewport. */
@media (max-height: 700px) {
  .hourglass-frame {
    max-width: 15rem !important;
  }
}
