/* Formohu design system — athletic editorial, bone/ink/orange/mustard */

@font-face {
  font-family: "Archivo";
  src: url("fonts/Archivo-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-stretch: 75% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --color-page: #f3ebdd;
  --color-paper: #fff9ee;
  --color-ink: #181916;
  --color-ink-soft: #34352f;
  --color-muted: #746e63;
  --color-rule: #c9bdaa;
  --color-orange: #d94a2b;
  --color-orange-bright: #ee5a34;
  --color-mustard: #d8a928;
  --color-positive: #47705a;
  --color-danger: #a52c22;
  --color-white: #ffffff;
  --color-surface-raised: #fff9ee;
  --font-display: "Archivo", "Arial Narrow", "Roboto Condensed", Arial, sans-serif;
  --font-body: "Archivo", Arial, sans-serif;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --rule-thin: 1px;
  --rule-heavy: 3px;
  --motion-fast: 140ms;
  --motion-normal: 180ms;
  --page-max: 1280px;
  --mobile-gutter: 16px;
  --rail-width: 220px;
  --bottom-nav-height: 56px;
  --focus-ring: 0 0 0 2px var(--color-page), 0 0 0 4px var(--color-orange);
  --shadow-hard: 2px 2px 0 var(--color-ink);
}

@media (min-width: 430px) {
  :root {
    --mobile-gutter: 20px;
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --color-page: #151613;
  --color-paper: #20211d;
  --color-ink: #f3ebdd;
  --color-ink-soft: #d3c7b6;
  --color-muted: #b8ad9d;
  --color-rule: #484940;
  --color-orange: #ed6848;
  --color-orange-bright: #f07a5c;
  --color-mustard: #e1b63b;
  --color-positive: #79a58a;
  --color-danger: #f07160;
  --color-white: #151613;
  --color-surface-raised: #292a25;
  --focus-ring: 0 0 0 2px var(--color-page), 0 0 0 4px var(--color-orange);
  --shadow-hard: 2px 2px 0 #000;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --color-page: #151613;
    --color-paper: #20211d;
    --color-ink: #f3ebdd;
    --color-ink-soft: #d3c7b6;
    --color-muted: #b8ad9d;
    --color-rule: #484940;
    --color-orange: #ed6848;
    --color-orange-bright: #f07a5c;
    --color-mustard: #e1b63b;
    --color-positive: #79a58a;
    --color-danger: #f07160;
    --color-white: #151613;
    --color-surface-raised: #292a25;
    --focus-ring: 0 0 0 2px var(--color-page), 0 0 0 4px var(--color-orange);
    --shadow-hard: 2px 2px 0 #000;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--color-ink);
  background: var(--color-page);
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--color-orange);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--color-orange-bright);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 var(--space-3);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 2.75rem); }
h2 { font-size: clamp(1.125rem, 3vw, 1.375rem); }
h3 { font-size: 1rem; font-weight: 700; }

p { margin: 0 0 var(--space-4); }

.tabular {
  font-variant-numeric: tabular-nums;
}

.label-caps {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.rule {
  border: 0;
  border-top: var(--rule-thin) solid var(--color-rule);
  margin: var(--space-6) 0;
}

.rule-heavy {
  border: 0;
  border-top: var(--rule-heavy) solid var(--color-ink);
  margin: var(--space-6) 0;
}

/* Layout */

.app-shell {
  display: grid;
  min-height: 100dvh;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "main"
    "bottomnav";
}

@media (min-width: 900px) {
  .app-shell {
    grid-template-columns: var(--rail-width) 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "rail main";
  }
}

.app-main {
  grid-area: main;
  padding: var(--mobile-gutter);
  padding-bottom: calc(var(--bottom-nav-height) + var(--mobile-gutter) + env(safe-area-inset-bottom, 0px));
  max-width: var(--page-max);
}

@media (min-width: 900px) {
  .app-main {
    padding: var(--space-8);
    padding-bottom: var(--space-8);
  }
}

.sheet {
  max-width: 42rem;
}

.sheet--wide {
  max-width: 56rem;
}

/* Desktop rail */

.app-rail {
  display: none;
  grid-area: rail;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  background: var(--color-paper);
  border-right: var(--rule-thin) solid var(--color-rule);
}

@media (min-width: 900px) {
  .app-rail {
    display: flex;
  }
}

.app-rail__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-6);
  border-bottom: var(--rule-thin) solid var(--color-rule);
  margin-bottom: var(--space-4);
  text-decoration: none;
  color: var(--color-ink);
}

.app-rail__brand img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
}

.app-rail__brand span {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.125rem;
  letter-spacing: 0.06em;
}

.app-rail__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Bottom navigation */

.app-bottomnav {
  grid-area: bottomnav;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  min-height: var(--bottom-nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--color-paper);
  border-top: var(--rule-heavy) solid var(--color-ink);
}

@media (min-width: 900px) {
  .app-bottomnav {
    display: none;
  }
}

/* Nav links */

.nav-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  flex: 1;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-1);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--color-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color var(--motion-fast);
}

.app-rail .nav-link {
  flex-direction: row;
  justify-content: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  border-radius: var(--radius-xs);
}

.nav-link:hover {
  color: var(--color-ink);
}

.nav-link--active {
  color: var(--color-ink);
}

.app-bottomnav .nav-link--active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: var(--color-orange);
}

.app-rail .nav-link--active {
  background: var(--color-page);
  border-left: 3px solid var(--color-orange);
  padding-left: calc(var(--space-4) - 3px);
}

.nav-link__icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: square;
}

.nav-link__badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 0.625rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  color: var(--color-paper);
  background: var(--color-orange);
  border-radius: var(--radius-xs);
}

.app-rail .nav-link__badge {
  position: static;
  margin-left: auto;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-5);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  border: var(--rule-thin) solid var(--color-ink);
  border-radius: var(--radius-xs);
  background: var(--color-paper);
  color: var(--color-ink);
  cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}

.btn:hover {
  background: var(--color-page);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--color-orange);
  border-color: var(--color-orange);
  color: var(--color-paper);
}

.btn--primary:hover {
  background: var(--color-orange-bright);
  border-color: var(--color-orange-bright);
  color: var(--color-paper);
}

.btn--ghost {
  background: transparent;
  border-color: var(--color-rule);
}

.btn--danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--color-paper);
}

.btn--block {
  display: flex;
  width: 100%;
}

/* Form fields */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field > span,
.field label > span {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.field input,
.field select,
.field textarea {
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-ink);
  background: var(--color-paper);
  border: var(--rule-thin) solid var(--color-ink);
  border-radius: var(--radius-xs);
}

.field textarea {
  min-height: 6rem;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.btn:focus-visible,
.nav-link:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Status */

.error,
.notice,
.status,
.offline-banner,
.install-callout {
  padding: var(--space-4);
  border-radius: var(--radius-xs);
  border: var(--rule-thin) solid var(--color-rule);
  margin-bottom: var(--space-4);
}

.error {
  border-color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 12%, var(--color-paper));
  color: var(--color-ink);
}

.notice,
.status--info {
  border-color: var(--color-rule);
  background: var(--color-paper);
}

.status--positive {
  border-color: var(--color-positive);
  background: color-mix(in srgb, var(--color-positive) 12%, var(--color-paper));
}

.status--warning {
  border-color: var(--color-mustard);
  background: color-mix(in srgb, var(--color-mustard) 15%, var(--color-paper));
}

.offline-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  border-color: var(--color-mustard);
  background: var(--color-mustard);
  color: var(--color-ink);
  font-weight: 700;
  text-align: center;
  margin: calc(-1 * var(--mobile-gutter)) calc(-1 * var(--mobile-gutter)) var(--space-4);
  padding: var(--space-3);
}

@media (min-width: 900px) {
  .offline-banner {
    margin: calc(-1 * var(--space-8)) calc(-1 * var(--space-8)) var(--space-4);
  }
}

.offline-banner[hidden] {
  display: none;
}

.install-callout {
  border: var(--rule-heavy) solid var(--color-ink);
  background: var(--color-paper);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.install-callout[hidden] {
  display: none;
}

/* Editorial components */

.hero-metric {
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 18vw, 6rem);
  font-weight: 900;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  margin: var(--space-4) 0;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: var(--rule-thin) solid var(--color-rule);
  margin-bottom: var(--space-4);
}

.section-header h2 {
  margin: 0;
}

.segmented {
  display: flex;
  border: var(--rule-thin) solid var(--color-ink);
  border-radius: var(--radius-xs);
  overflow: hidden;
}

.segmented__item {
  flex: 1;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--color-paper);
  border: none;
  border-right: var(--rule-thin) solid var(--color-ink);
  color: var(--color-muted);
  cursor: pointer;
}

.segmented__item:last-child {
  border-right: none;
}

.segmented__item--active {
  background: var(--color-orange);
  color: var(--color-paper);
}

.calorie-bar {
  display: flex;
  height: 12px;
  border: var(--rule-thin) solid var(--color-ink);
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--color-paper);
}

.calorie-bar__segment {
  height: 100%;
  transition: width var(--motion-normal);
}

.calorie-bar__segment--eaten {
  background: var(--color-orange);
}

.calorie-bar__segment--remaining {
  background: var(--color-rule);
}

.food-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-rule);
  padding-bottom: var(--space-3);
}

.food-tab {
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
  color: var(--color-ink-muted);
  border-bottom: 2px solid transparent;
}

.food-tab--active {
  color: var(--color-ink);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

.food-quick-form {
  display: grid;
  gap: var(--space-4);
}

.food-search-results {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.meal-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: var(--rule-thin) solid var(--color-rule);
}

.meal-row__name {
  font-weight: 600;
}

.meal-row__meta {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.meal-row__kcal {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.intervention {
  padding: var(--space-5);
  border: var(--rule-heavy) solid var(--color-ink);
  background: var(--color-paper);
}

.intervention--brutal {
  background: var(--color-orange);
  border-color: var(--color-orange);
  color: var(--color-paper);
}

.intervention__label {
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.intervention__statement {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: var(--space-2);
}

/* Gallery */

.gallery-grid {
  display: grid;
  gap: var(--space-8);
}

.gallery-section {
  padding-bottom: var(--space-6);
  border-bottom: var(--rule-thin) solid var(--color-rule);
}

.gallery-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.swatch {
  width: 72px;
  text-align: center;
}

.swatch__chip {
  height: 48px;
  border: var(--rule-thin) solid var(--color-ink);
  border-radius: var(--radius-xs);
  margin-bottom: var(--space-2);
}

.swatch__label {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-muted);
}

.gallery-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: var(--rule-thin) solid var(--color-rule);
}

/* HTMX */

.htmx-request .htmx-indicator {
  opacity: 1;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity var(--motion-fast);
}

/* Reduced motion */

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

  .btn:active {
    transform: none;
  }

  .calorie-bar__segment {
    transition: none;
  }
}

/* Auth pages (no nav) */

.auth-shell {
  display: flex;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: var(--mobile-gutter);
}

.auth-shell .sheet {
  width: 100%;
  max-width: 24rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.auth-brand img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
}

.auth-brand span {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
}

.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;
}

/* Today */

.today-header__date {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin: 0;
}

.today-subline {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin: var(--space-2) 0;
}

.today-section {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: var(--rule-thin) solid var(--color-rule);
}

.today-section--secondary {
  opacity: 0.92;
}

.field--hero input.weigh-in-input {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 12vw, 3.5rem);
  font-weight: 900;
  text-align: center;
  padding: var(--space-4);
  font-variant-numeric: tabular-nums;
}

.weight-chart-wrap {
  margin: var(--space-4) 0;
  max-width: 100%;
  overflow-x: auto;
}

.weight-chart-wrap--large .weight-chart {
  min-width: 320px;
}

.weight-chart {
  width: 100%;
  height: auto;
  display: block;
}

.weight-chart__raw {
  fill: none;
  stroke: var(--color-muted);
  stroke-width: 1;
  opacity: 0.5;
}

.weight-chart__ma {
  fill: none;
  stroke: var(--color-orange);
  stroke-width: 2.5;
}

.weight-chart__dot {
  fill: var(--color-muted);
}

.weight-chart__milestone {
  stroke: var(--color-rule);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.weight-chart__label {
  font-size: 8px;
  fill: var(--color-muted);
}

.weight-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-top: var(--space-3);
}

.weight-table th,
.weight-table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--rule-thin) solid var(--color-rule);
}

.weight-table__today {
  font-weight: 700;
}

.activity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: var(--rule-thin) solid var(--color-rule);
}

.btn--small {
  min-height: 36px;
  padding: var(--space-2) var(--space-3);
  font-size: 0.75rem;
}

