/*
 * Follow design system - Daily Rhythm.
 *
 * One layout language across both brands: warm off-white ground, dark ink,
 * generous whitespace, softly rounded cards, a graceful serif reserved for
 * headline greetings and a humanist sans everywhere else.
 *
 * Flavour keeps Daily Rhythm's muted terracotta. Fitness takes the Performance
 * Studio cobalt and a cooler ground (D3), so the two sides are unmistakable
 * without becoming two different products.
 *
 * Brand colours arrive as custom properties set on <body> from the active
 * brand, so nothing here hard-codes which brand is showing.
 */

:root {
  --ink: #232824;
  --ink-soft: #5c6560;
  --ink-faint: #8b938e;
  --line: rgba(35, 40, 36, 0.12);
  --line-soft: rgba(35, 40, 36, 0.06);

  --radius: 22px;
  --radius-sm: 14px;
  --radius-pill: 999px;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --shadow: 0 1px 2px rgba(35, 40, 36, 0.04), 0 12px 28px rgba(35, 40, 36, 0.06);
}

/* ------------------------------------------------------------- viewport ---

   The page is locked to the width of the screen it is on. A phone should only
   ever scroll up and down: a page that also drifts sideways under your thumb
   reads as broken, and one stray wide element is enough to do it to every
   page at once. So the width is clamped here, once, and the rules underneath
   stop the usual culprits - the header row, a wide form control, an image,
   a table, a long unbroken word - from pushing past the edge in the first
   place. The clamp is the safety net, not the fix.

   `clip` is preferred over `hidden` because it does not turn the element into
   a scroll container, so a sticky header added later still sticks. Browsers
   without it take the `hidden` above.
   -------------------------------------------------------------------------- */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  background: var(--surface, #faf8f4);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 4rem;
  /* A pasted URL or a long food name should fold, not widen the page. */
  overflow-wrap: break-word;
}

/* Replaced and form elements carry their own intrinsic width, which is
   routinely wider than a phone. None of them may exceed their column. */
img,
svg,
video,
canvas,
iframe,
table {
  max-width: 100%;
}

img,
video {
  height: auto;
}

/* A table deliberately put in Bootstrap's scroller is the exception: there it
   should keep its natural width and scroll inside the box, not squeeze. */
.table-responsive > table {
  max-width: none;
}

input,
select,
textarea,
.form-control,
.form-select {
  max-width: 100%;
}

/* A flex or grid child refuses to shrink below its content unless told it
   may, which is what turns one long row into a sideways scroll. */
.follow-row > *,
.follow-footer > *,
.follow-mark > * {
  min-width: 0;
}

/* On a phone a row of controls that does not fit should fold onto the next
   line rather than squeeze - squeezing is what broke "Draft a plan" into
   three lines and pushed the last pill off the screen. Anything that must
   stay on one line says so with Bootstrap's own .flex-nowrap, which wins
   here because its utilities are !important. */
@media (max-width: 36rem) {
  .d-flex:not(.flex-nowrap):not(.flex-column) {
    flex-wrap: wrap;
  }
}

/* ---------------------------------------------------------------- type --- */

.follow-greeting {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin-bottom: 0.25rem;
}

.follow-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-faint);
}

.follow-lede { color: var(--ink-soft); }

h1, h2, h3, h4 { letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }

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

/* --------------------------------------------------------------- chrome --- */

/* The chrome is two rows, the same on a phone and a desktop.

   First: the wordmark, and the Flavour/Fitness switch in the top right. Which
   of the two brands you are in is the thing that changes most about the page,
   so it sits with the name of the brand rather than among the member's own
   controls.

   Second: you and your Inbox on the left, and the sections burger on the
   right. Both rows fold rather than overflow if a workspace name is long
   enough to need it. */
.follow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 1.25rem 0 0.25rem;
}

.follow-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  padding: 0.25rem 0;
}

/* Basis zero so the nav takes the room that is left rather than asking for
   the room its sections would like: the actions on the left keep their place
   and the nav folds to its burger instead of pushing them onto another line.
   Its contents sit at the end of that room, so the burger is against the
   right edge whether or not the sections fit as a row of pills. */
.follow-bar .follow-nav {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.25rem 0;
  justify-content: flex-end;
}

/* Folded, this nav is the burger and nothing else. Every other nav keeps the
   current section beside the button, but this one shares its row with Inbox
   and the monogram, so on a phone there is no room for a second pill and the
   page heading says where you are anyway. */
.follow-bar .follow-nav[data-collapsible] { flex: 0 0 auto; }

.follow-bar .follow-nav[data-collapsible]:not([data-open]) .follow-nav__list > a {
  display: none;
}

.follow-bar__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  min-width: 0;
}

/* A workspace is named by whoever made it, so it is the one thing in the
   chrome with no width to budget for. Where the row is tight it gives way
   first, to an ellipsis and the full name in a tooltip, rather than pushing
   the monogram onto a line of its own. */
@media (max-width: 48rem) {
  .follow-bar__actions .follow-bar__workspace {
    max-width: min(11rem, 34vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.follow-wordmark {
  font-family: var(--serif);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
}

.follow-wordmark span { color: var(--accent); }

.follow-monogram {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  text-decoration: none;
}

/* The two-option mode switch, present on every page of both brands. */
.follow-switch {
  display: inline-flex;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.2rem;
  gap: 0.2rem;
}

.follow-switch button {
  border: 0;
  background: transparent;
  border-radius: var(--radius-pill);
  padding: 0.35rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}

.follow-switch button[aria-current="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* A nav is a row of pills on anything wider than a phone. On a phone it is a
   burger and a menu instead, so a Fitness nav of twelve sections costs one row
   rather than three, and adding a thirteenth costs nothing.

   The links live in .follow-nav__list, which is display: contents so that on a
   wide screen they lay out in the nav's own row exactly as if the wrapper were
   not there. Below the breakpoint the wrapper becomes the menu.

   Only the current section stays visible beside the burger when the menu is
   shut: a nav that shows nothing at all leaves you with no idea where you are.

   A five-destination shell is still the right answer for Fitness; this makes
   the twelve that exist cost one row until then. */
.follow-nav {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem 0 0.25rem;
}

.follow-nav__list { display: contents; }

.follow-nav__toggle {
  display: none;
  align-items: center;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: var(--radius-pill);
  padding: 0.45rem 0.7rem;
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
}

.follow-nav__toggle svg { display: block; }

.follow-nav__toggle[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-strong);
}

.follow-nav a {
  white-space: nowrap;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--ink-soft);
  text-decoration: none;
}

.follow-nav a:hover { background: var(--line-soft); color: var(--ink); }
.follow-nav a[aria-current="page"] { background: var(--accent); color: var(--accent-contrast); }

/* Collapsed. The server renders every nav collapsed so a phone never flashes
   a full row of pills before the script reaches it; the script then expands
   any nav whose sections fit on one line, at whatever width that happens to
   be, and collapses it again when the window narrows. There is no breakpoint
   in this: a nav collapses when it does not fit, so adding a section is free.
   With JavaScript off, the <noscript> rule in base.html hides the button and
   leaves the pills. */
.follow-nav[data-collapsible] .follow-nav__toggle { display: inline-flex; }

.follow-nav[data-collapsible]:not([data-open]) .follow-nav__list > a:not([aria-current="page"]) {
  display: none;
}

/* Open, the wrapper stops being invisible and becomes the menu itself: a card
   on its own line under the burger, one section per row. */
/* Laid over the page rather than pushed into it, so opening the menu does not
   move the row it hangs from or the page underneath. */
.follow-nav[data-collapsible][data-open] .follow-nav__list {
  position: absolute;
  top: 100%;
  /* Hung from the same edge as the button it belongs to, which for the brand
     nav is the right one. */
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 12rem;
  max-width: min(20rem, 100%);
  padding: 0.35rem;
  background: var(--surface-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.follow-bar .follow-nav[data-collapsible][data-open] .follow-nav__list {
  left: auto;
  right: 0;
}

.follow-nav[data-collapsible][data-open] .follow-nav__list > a {
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- cards --- */

.follow-card {
  background: var(--surface-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem;
}

.follow-card--tight { padding: 1rem 1.15rem; }
.follow-card--flat { box-shadow: none; border-color: var(--line); }

.follow-card__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 650;
  color: var(--accent-strong);
}

/* --------------------------------------------------------------- pieces --- */

.follow-stat { display: flex; flex-direction: column; gap: 0.1rem; }
.follow-stat__value {
  font-size: 1.5rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.follow-stat__label { font-size: 0.78rem; color: var(--ink-faint); }

.follow-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.follow-row:last-child { border-bottom: 0; }

.follow-tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 650;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.follow-tag--quiet { background: var(--line-soft); color: var(--ink-soft); }
.follow-tag--warn { background: #fdf0d9; color: #8a5a10; }

.follow-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem;
}

.follow-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--ink-faint);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* -------------------------------------------------------------- actions --- */

.btn-follow,
.btn-follow-quiet,
.btn-follow-bare {
  /* Buttons and button-shaped links must look identical, so the link
     underline Bootstrap applies is removed here rather than per template. */
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  /* A pill breaking its own label over three lines is worse than the row of
     pills folding, which is what the row now does on a phone. */
  white-space: nowrap;
}

.btn-follow {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 0;
  border-radius: var(--radius-pill);
  padding: 0.6rem 1.4rem;
  font-weight: 600;
}
.btn-follow:hover, .btn-follow:focus { background: var(--accent-strong); color: var(--accent-contrast); }

.btn-follow-quiet {
  background: transparent;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 0.5rem 1.15rem;
  font-weight: 600;
}
.btn-follow-quiet:hover { background: var(--accent-soft); }

/* The narrowest phones. Both chrome rows are a few pixels short of fitting
   at 320px, so the wordmark, the switch and the pills each give up a little
   rather than any of them dropping onto a row of its own. */
@media (max-width: 26rem) {
  /* Buys back the width both rows need on the narrowest phones. */
  .follow-wordmark { font-size: 1.15rem; }
  .follow-switch button { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
  .btn-follow-quiet { padding: 0.45rem 0.75rem; font-size: 0.85rem; }
  .follow-monogram { width: 2rem; height: 2rem; }
}

.btn-follow-bare {
  background: transparent;
  border: 0;
  color: var(--ink-faint);
  padding: 0.2rem 0.45rem;
  font-size: 0.85rem;
}
.btn-follow-bare:hover { color: var(--ink); }

/* --------------------------------------------------------------- forms --- */

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--line);
  padding: 0.55rem 0.8rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem var(--accent-soft);
}
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }

a { color: var(--accent-strong); }

/* --------------------------------------------------------------- utils --- */

.follow-week {
  display: grid;
  /* min() so the track can fall below 160px on the narrowest phones rather
     than forcing the grid wider than the screen. */
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 0.75rem;
}

.follow-day--today { border-color: var(--accent); }

.follow-checked { text-decoration: line-through; color: var(--ink-faint); }

.htmx-request .follow-busy { opacity: 0.55; transition: opacity 120ms ease; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --------------------------------------------------------------------------
   Workspaces

   A workspace brings its own colour. It is scoped to these blocks rather than
   set on the body, so a professional's brand never redefines the Follow
   accent the member's own pages are built from.
   -------------------------------------------------------------------------- */

.follow-workspace-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 0.75rem;
  background: var(--ws-accent);
  color: var(--ws-contrast);
}

.follow-workspace-bar__mark {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--ws-contrast);
  color: var(--ws-accent);
  font-weight: 600;
}

.follow-provider-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 3px solid var(--ws-accent);
}

.follow-provider-logo {
  width: 4rem;
  height: 4rem;
  border-radius: 0.9rem;
  object-fit: cover;
}

.follow-provider-logo--letter {
  display: grid;
  place-items: center;
  background: var(--ws-accent);
  color: var(--ws-contrast);
  font-size: 1.8rem;
  font-weight: 600;
}

.follow-cover {
  width: 100%;
  max-height: 14rem;
  object-fit: cover;
  border-radius: 0.9rem;
}

.follow-swatch {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 0.6rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Inbox
   -------------------------------------------------------------------------- */

.follow-notification {
  display: grid;
  gap: 0.15rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line-soft);
  color: inherit;
  text-decoration: none;
}

.follow-notification:last-child { border-bottom: 0; }
.follow-notification:hover { background: var(--accent-soft); }

.follow-notification__kind {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft, #6b6b6b);
}

.follow-notification__title { font-weight: 600; }

/* Unread is a bar and a word, never colour alone (S08). */
.follow-notification--unread {
  border-left: 3px solid var(--accent);
  padding-left: 0.7rem;
}

.follow-badge {
  display: inline-block;
  min-width: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

/* Bookings and the shared week
   -------------------------------------------------------------------------- */

.follow-booking-service {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.follow-booking-service:last-child { border-bottom: 0; }

/* The week draws both brands at once. The brand you are in keeps full
   contrast; the other side is legible but quiet, so one week reads as one
   thing rather than two lists stacked. */
.follow-week-entry--other { opacity: 0.72; }
.follow-week-entry--other .follow-tag { background: var(--line-soft); color: var(--ink-soft); }

/* Progress photo timeline
   -------------------------------------------------------------------------- */

/* Alpine sets x-show after it boots. Without this the whole stack of frames
   flashes on screen for a moment before collapsing to one, which is the exact
   opposite of what a timeline is for. */
[x-cloak] { display: none !important; }

/* A fixed frame height stops the page jumping as you scrub: portrait and
   landscape photos in the same run would otherwise shift everything below
   them on every step. */
.follow-timeline {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 18rem;
}

.follow-timeline__frame { margin: 0; text-align: center; }

.follow-timeline__frame img {
  max-height: 32rem;
  border-radius: var(--radius-sm);
}

/* A progression line. Drawn as SVG on the server: a charting library is a
   quarter of a megabyte to put a line through nine points, and it draws
   nothing at all until it has loaded, which on gym wifi is a while. */
.follow-chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.follow-chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.follow-chart__latest { fill: var(--accent); }

.follow-chart__scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* The heaviest thing on the screen mid-session, because it is the number
   being chased and the phone is on a bench two feet away. */
.follow-mark {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  align-items: baseline;
}

.follow-mark__value {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Cook mode is read from across a worktop, so the step is set larger than
   anything else on the site and the ingredient rows are a comfortable target
   for a hand that has just been in a mixing bowl. */
.follow-cook__step {
  font-size: 1.35rem;
  line-height: 1.5;
  margin: 0;
}

.follow-cook__ingredient { cursor: pointer; padding-block: 0.6rem; }

.follow-cook__got { text-decoration: line-through; color: var(--ink-faint); }

/* The pages an import was read from. A recipe screenshotted across four
   images has to be checkable against the draft, so they are shown as a grid
   that wraps rather than a row that scrolls sideways: on a phone that is one
   column, and nothing here needs a sideways swipe. */
.follow-pages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.75rem;
}

.follow-pages__page { margin: 0; }

.follow-pages__page img {
  border-radius: var(--radius);
  width: 100%;
  max-height: 24rem;
  object-fit: contain;
}
