/*
 * theme.css — Sundial Habits design tokens.
 * Washed cream and blush, white cards floating on barely-there shadows.
 * Everything gently rounded — a shared notebook on the kitchen counter.
 */

:root {
  --canvas: #fbf6f1;
  --surface: #fdfbf9;
  --surface-2: #f3e7e0;
  --border: #ecdfd5;
  --border-strong: #d9c3b6;
  --ink: #3a2e39;
  --muted: #71636a;
  --accent: #6b4f63;
  --accent-hover: #593f4f;
  --accent-ink: #fbf6f1;
  --accent-text: #90585e;
  --accent-strong: #6b4152;
  --accent-soft: #f2dde3;
  --accent-border: #e2c1cb;
  --success: #5c8a63;
  --success-ink: #ffffff;
  --success-soft: #e3ede4;
  --success-strong: #3f6b47;
  --warning: #b8823f;
  --warning-ink: #ffffff;
  --warning-soft: #f3e6d3;
  --warning-strong: #7a4f1d;
  --danger: #b1584f;
  --danger-ink: #ffffff;
  --danger-soft: #f5e0dd;
  --danger-strong: #8a3f38;
  --chart-1: #c98a9e;
  --chart-2: #8fa888;
  --chart-3: #d9a05b;
  --chart-4: #8896c4;
  --chart-5: #c97a4a;
  --chart-6: #a68bc9;

  /* This app's own tokens — the two partner colours used throughout.
     -ink is text ON the -rose/-sage fill (a dot, a swatch); -text is that
     hue used AS text on the page's own surfaces (the streak numeral). */
  --x-rose: #c98a9e;
  --x-sage: #8fa888;
  --x-rose-soft: #f5e3e8;
  --x-sage-soft: #e7eee4;
  --x-rose-ink: #4a1f30;
  --x-sage-ink: #23361f;
  --x-rose-text: #4a1f30;
  --x-sage-text: #23361f;

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

  --radius-btn: 999px;
  --radius-card: 1.25rem;
  --radius-input: 0.875rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --border-w: 1px;
  --border-strong-w: 1px;
  --card-pad: 1.5rem;
  --btn-weight: 600;
  --caps: none;
  --caps-tracking: 0;
  --shadow-card: 0 1px 2px color-mix(in srgb, var(--ink) 6%, transparent), 0 14px 32px -18px color-mix(in srgb, var(--ink) 30%, transparent);
  --shadow-raised: 0 24px 48px -20px color-mix(in srgb, var(--ink) 35%, transparent), 0 2px 8px color-mix(in srgb, var(--ink) 10%, transparent);
  --shadow-btn: 0 6px 16px -6px color-mix(in srgb, var(--accent) 55%, transparent);
}

html[data-theme="dark"] {
  --canvas: #241c22;
  --surface: #2d232a;
  --surface-2: #382c34;
  --border: #46373f;
  --border-strong: #5c4a54;
  --ink: #f4ebe7;
  --muted: #b9a9b1;
  --accent: #dcaebb;
  --accent-hover: #e6c0cb;
  --accent-ink: #2d1e26;
  --accent-text: #e8b2ba;
  --accent-strong: #f0c9d1;
  --accent-soft: #3f2d37;
  --accent-border: #5c4453;
  --success: #86b98a;
  --success-ink: #163019;
  --success-soft: #253524;
  --success-strong: #aed4b1;
  --warning: #dba766;
  --warning-ink: #2e1f10;
  --warning-soft: #3a2c1a;
  --warning-strong: #eec48b;
  --danger: #dd9088;
  --danger-ink: #331211;
  --danger-soft: #3c2320;
  --danger-strong: #f1b0a8;
  --chart-1: #dcaebb;
  --chart-2: #a8c8a1;
  --chart-3: #e0b57a;
  --chart-4: #a8b3e0;
  --chart-5: #e0a37a;
  --chart-6: #c3a8e0;

  --x-rose: #dcaebb;
  --x-sage: #a8c8a1;
  --x-rose-soft: #3f2d34;
  --x-sage-soft: #2c342a;
  --x-rose-ink: #4a1f30;
  --x-sage-ink: #23361f;
  --x-rose-text: #dcaebb;
  --x-sage-text: #a8c8a1;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 32px -18px rgba(0, 0, 0, 0.55);
  --shadow-raised: 0 24px 48px -20px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-btn: 0 6px 16px -6px color-mix(in srgb, var(--accent) 45%, transparent);
}

/*
 * app.css — Hearth's own ground: the app shell, the header, the weekly
 * grid, the streak band, the bottom tab bar, and the icon/colour pickers on
 * the habit form. Everything reads a token; nothing here is a literal
 * colour — every wash is color-mix over a token or the habit's own chosen
 * colour, held in the --hc / --dot / --sw custom properties as DATA, not as
 * part of the design system.
 */

/* ---- Shell -------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.board-main {
  flex: 1 1 auto;
  padding-bottom: 6.5rem; /* clears the fixed bottom tab bar on phone width */
}

@media (min-width: 768px) {
  .board-main {
    padding-bottom: 3rem;
  }
}

/* ---- Header --------------------------------------------------------------
   Never sticky, never blurred — the brief is explicit. Plain flow. */
.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.75rem 1.25rem 1.25rem;
  max-width: 46rem;
  margin: 0 auto;
}
@media (min-width: 768px) {
  .board-header {
    padding: 2.5rem 1.5rem 1.5rem;
  }
}

.board-header-date {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.board-header-day {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: var(--display-tracking);
}
@media (min-width: 768px) {
  .board-header-day {
    font-size: 1.875rem;
  }
}
.board-header-num {
  margin-top: 0.125rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.board-header-people {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.partner-dot {
  display: inline-flex;
  height: 2rem;
  width: 2rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--dot);
  color: var(--dot-ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8125rem;
  box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--dot) 60%, transparent);
}

/* ---- Weekly grid ---------------------------------------------------------- */
.week-board {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}
@media (min-width: 768px) {
  .week-board {
    padding: 0 1.5rem;
  }
}

.habit-list {
  display: flex;
  flex-direction: column;
}
.habit-row {
  padding: 1.125rem 1.25rem;
  transition: opacity 0.45s var(--ease-out, ease), transform 0.45s var(--ease-out, ease);
  transition-delay: var(--stagger-delay, 0s);
}
/* Rests visible (no JS, or JS still loading): the grid is never blank.
   app.js adds .will-enter for one frame, then swaps it for .is-in — the
   entrance is JS animating AWAY FROM an offset, not the page starting hidden. */
.habit-row.will-enter {
  opacity: 0;
  transform: translateY(10px);
}
.habit-row.is-in {
  opacity: 1;
  transform: none;
}
html.reduced-motion .habit-row {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}
.habit-row + .habit-row {
  border-top: 1px solid var(--border);
}

.habit-row-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.habit-icon {
  display: inline-flex;
  height: 2rem;
  width: 2rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--hc) 22%, var(--surface));
  color: color-mix(in srgb, var(--hc) 70%, var(--ink));
}
.habit-icon .icon {
  height: 1.05rem;
  width: 1.05rem;
}
.habit-row-name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.habit-row-dot {
  height: 0.5rem;
  width: 0.5rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--dot);
}
.habit-row-edit {
  margin-left: auto;
  flex-shrink: 0;
}
.habit-row-streak {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-text);
  min-width: 2.25rem;
  justify-content: flex-end;
}
.habit-row-streak .icon {
  height: 0.9rem;
  width: 0.9rem;
}

.habit-row-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.375rem;
  margin-top: 0.75rem;
}
@media (min-width: 640px) {
  .habit-row-days {
    gap: 0.625rem;
  }
}

.day-cell {
  position: relative;
  display: flex;
  aspect-ratio: 1 / 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--hc) 8%, var(--surface));
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.day-cell:hover {
  transform: translateY(-1px);
}
.day-cell:active {
  transform: translateY(0);
}
.day-cell-letter {
  font-size: 0.6875rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--hc) 65%, var(--muted));
}
.day-cell.is-done {
  background: var(--hc);
  border-color: transparent;
  box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--hc) 70%, transparent);
}
.day-cell.is-done .day-cell-letter {
  color: color-mix(in srgb, white 88%, var(--hc));
  opacity: 0.85;
}
.day-cell-check {
  position: absolute;
  height: 1rem;
  width: 1rem;
  color: color-mix(in srgb, white 92%, var(--hc));
}
.day-cell.is-today {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
.day-cell.is-done.is-today {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent), 0 6px 14px -8px color-mix(in srgb, var(--hc) 70%, transparent);
}

/* ---- Streak band ----------------------------------------------------------
   A single tinted strip; each partner's number as one big serif numeral. */
.streak-band {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1px;
  margin-top: 1.25rem;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--border);
  box-shadow: var(--shadow-card);
}
.streak-band-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.125rem 1.375rem;
  background: var(--surface-2);
}
.streak-band-num {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 2.25rem;
  line-height: 1;
  letter-spacing: var(--display-tracking);
}
.streak-band-name {
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
}
.streak-band-name small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  font-family: var(--font-mono);
}

.board-footer {
  margin-top: 1.25rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---- Bottom tab bar --------------------------------------------------------
   A thumb-height bar on phone width; a slim static strip on desktop, moved
   above the header with `order`. */
.tab-bar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 0.5rem;
  padding: 0.625rem 1rem calc(0.625rem + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-raised);
}
.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted);
}
.tab-bar-item.is-active {
  color: var(--accent-text);
}
.tab-bar-item .icon {
  height: 1.15rem;
  width: 1.15rem;
}
.tab-bar-item-brand {
  font-family: var(--font-display);
}
.tab-bar-fab {
  display: inline-flex;
  height: 3.25rem;
  width: 3.25rem;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  margin-top: -1.5rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-btn);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.tab-bar-fab:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.tab-bar-fab .icon {
  height: 1.5rem;
  width: 1.5rem;
}

@media (min-width: 768px) {
  .tab-bar {
    position: static;
    order: -1;
    justify-content: center;
    gap: 2.5rem;
    padding: 0.875rem 1.5rem;
    box-shadow: none;
    border-top: none;
    border-bottom: 1px solid var(--border);
  }
  .tab-bar-fab {
    height: 2.5rem;
    width: 2.5rem;
    margin-top: 0;
  }
  .tab-bar-fab .icon {
    height: 1.15rem;
    width: 1.15rem;
  }
}

/* ---- Habit form: icon strip ------------------------------------------------ */
.icon-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.icon-choice {
  position: relative;
  display: inline-flex;
  height: 2.5rem;
  width: 2.5rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.icon-choice input {
  /* Visually hidden without opacity: 0 — a checker reading every element's
     rest state after an htmx swap cannot tell "permanently off-screen form
     control" from "entrance animation stuck at its start", and opacity: 0
     reads as the latter. Clipped-to-nothing stays invisible without ever
     resting below full opacity. */
  position: absolute;
  height: 1px;
  width: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.icon-choice:has(input:checked) {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.icon-choice:has(input:focus-visible) {
  outline: none;
  box-shadow: var(--ring);
}

/* ---- Habit form: colour ring ------------------------------------------------ */
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
}
.swatch {
  height: 2.25rem;
  width: 2.25rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--sw);
  border: 2px solid transparent;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.swatch:hover {
  transform: translateY(-1px);
}
.swatch.is-active {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw);
}
.swatch-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  overflow: hidden;
  border: 2px dashed var(--border-strong);
  background: var(--surface);
}
.swatch-custom input[type="color"] {
  height: 100%;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
.swatch-custom input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
.swatch-custom input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 999px;
}
