/* ============================================================
   ClearBeat Health Apps — clearbeat.com.au
   Prototype stylesheet (desktop + mobile)
   ============================================================ */

:root {
  /* Brand: Beat Red #EC3013 · Ink #201E1D · Ground #F3F2F2 */
  --red: #ec3013;
  --red-dark: #c9270e;
  --ink: #201e1d;
  --ink-soft: #4d4a48;
  --ink-faint: #6c6763; /* AA contrast (≥4.5:1) on both --bg and --surface */
  --bg: #f3f2f2;
  --surface: #ffffff;
  --line: #e4e1df;
  /* Per-app accents (ChemPal #0f5c50, Fluid Tracker #1e88c9) are not tokens —
     each app carries its own as an inline --accent from data/apps.json, so
     adding an app never needs a rule here. */
  --radius: 20px;
  --shadow-sm: 0 1px 2px rgba(22, 22, 26, 0.05), 0 4px 14px rgba(22, 22, 26, 0.06);
  --shadow-lg: 0 2px 6px rgba(22, 22, 26, 0.07), 0 24px 60px rgba(22, 22, 26, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-display: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { font-family: var(--font-display); }

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- header ---------- */

/* Flat and opaque, at exactly --bg. iOS fills the status-bar area from
   <meta name="theme-color">, which is a single flat colour — so a translucent
   blurred header can never match it: it sat ~#f6f5f2 at rest and drifted
   further as content scrolled under the blur, leaving a seam along the top of
   the page. Header, theme-color and the manifest's theme_color are now the one
   value; change them together. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* the symbol is a square tile — never round its corners */
.brand img { width: 40px; height: 40px; }

.brand-text { line-height: 1.15; }

/* wordmark: Archivo — "Clear" 500, "Beat" 700, tracking -0.04em */
.brand-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.brand-name b { font-weight: 700; }

/* HEALTH APPS: Archivo 600, tracking 0.3em */
.brand-tag {
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.site-nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-soft);
  transition: color 0.15s ease;
}

.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); }

.site-nav a[aria-current="page"] { font-weight: 700; }

.btn {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

/* buttons use the darker brand red so white label text meets AA contrast */
.btn-primary { background: var(--red-dark); color: #fff; }
.btn-primary:hover { background: #a81f0a; transform: translateY(-1px); }

.btn-ghost { border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); transform: translateY(-1px); }

.site-nav .btn { padding: 10px 22px; color: #fff; }

/* mobile nav */

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  width: 44px;
  height: 44px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- hero ---------- */

.hero { padding: 60px 0 40px; overflow: hidden; }

.hero .container {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 48px;
  align-items: center;
}

.kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--red-dark); /* darker red: AA contrast for small caps text */
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(2.3rem, 4.6vw, 3.6rem);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 22px;
}

.hero p.lead {
  font-size: 1.15rem;
  color: var(--ink-soft);
  max-width: 34em;
  margin-bottom: 34px;
}

.hero-ctas { display: flex; gap: 14px; flex-wrap: wrap; }

/* two overlapping phones */

.hero-phones {
  position: relative;
  height: 560px;
}

.hero-phones .phone {
  position: absolute;
  width: 240px;
}

.hero-phones .phone:nth-child(1) {
  left: 6%;
  top: 40px;
  transform: rotate(-5deg);
  z-index: 1;
}

.hero-phones .phone:nth-child(2) {
  right: 4%;
  top: 0;
  transform: rotate(4deg);
  z-index: 2;
}

/* ---------- phone frame ---------- */

.phone {
  border-radius: 40px;
  background: #111114;
  padding: 10px;
  box-shadow: var(--shadow-lg);
}

.phone img {
  border-radius: 31px;
  width: 100%;
  height: auto; /* keep aspect ratio — the height attribute must not fix it */
}

/* ---------- sections ---------- */

/* anchored sections stop below the sticky header when scrolled to */
section { padding: 72px 0; scroll-margin-top: 72px; }

/* the Our Apps intro leads straight into the first showcase */
#apps { padding-bottom: 8px; }
#apps .section-head { margin-bottom: 0; }

.section-head { max-width: 620px; margin-bottom: 48px; }

.section-head h2 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin-bottom: 14px;
}

.section-head p { color: var(--ink-soft); font-size: 1.05rem; }

.app-card .links { margin-top: auto; display: flex; gap: 12px; flex-wrap: wrap; }

.text-link {
  font-weight: 600;
  color: var(--red-dark);
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.15s ease;
}

.text-link:hover { border-color: var(--red); }

/* why clearbeat */

.values { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.value-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 36px;
}

.value h3 { font-size: 1.05rem; font-weight: 700; margin: 14px 0 8px; }
.value p { font-size: 0.93rem; color: var(--ink-soft); }

.value .dot {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #fce7e1;
  color: var(--red);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

/* about */

.about .container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: start;
}

.about p { color: var(--ink-soft); margin-bottom: 16px; }

/* contact / footer */

.contact {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

.contact h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
.contact p { color: #b9b9c0; }

.site-footer { padding: 40px 0 56px; }

.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--ink-faint);
}

.footer-links { display: flex; gap: 24px; }
.footer-links a:hover { color: var(--ink); }

/* ---------- app grid (home) ---------- */

/* auto-fill, so the grid takes however many apps there are without a rule
   change — two fills a row today, a third wraps, and nothing here changes */
.app-grid {
  display: grid;
  /* min() floor, or the 280px track overflows a narrower phone */
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 24px;
}

.app-card {
  position: relative; /* anchors the stretched toggle below */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--line);
  border-radius: var(--radius);
  padding: 26px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.app-card:hover {
  box-shadow: inset 0 0 0 2px var(--accent);
  transform: translateY(-2px);
}

.app-card .icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 4px;
}

.app-card .app-kind {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.app-card h3 { font-size: 1.35rem; letter-spacing: -0.03em; }

.app-card .blurb { color: var(--ink-soft); font-size: 0.95rem; }

/* pins the chip and the toggle to the bottom so cards of uneven copy line up */
.app-card .app-status { margin-top: auto; padding-top: 8px; }

.app-card-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

/* stretched over the whole card, so clicking anywhere opens the panel —
   the card can't be one big <button>, since a button can't wrap the <h3> */
.app-card-toggle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.app-card-toggle:focus-visible { outline: 2px solid var(--red); outline-offset: 4px; }

.app-card-toggle .chev { transition: transform 0.2s ease; }

.app-card.is-open { box-shadow: inset 0 0 0 2px var(--accent); }
.app-card.is-open .chev { transform: rotate(180deg); }

/* ---------- app screenshot panel (home) ---------- */

/* Sits after the whole grid rather than between cards — a full-bleed panel
   spliced into the grid would break the row it interrupts. */
.app-panel {
  margin-top: 24px;
  scroll-margin-top: 88px; /* clears the sticky header when scrolled into view */
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--line);
  border-radius: var(--radius);
  padding: 28px 26px 32px;
  animation: panel-in 0.22s ease both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(-6px); }
}

.app-panel-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 26px;
}

.app-panel-head .icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.app-panel-head .app-kind {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.app-panel-head h3 { font-size: 1.3rem; letter-spacing: -0.03em; }

.app-panel-close {
  margin-left: auto;
  align-self: flex-start;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  color: var(--ink-faint);
  box-shadow: inset 0 0 0 2px var(--line);
  transition: color 0.15s ease, box-shadow 0.15s ease;
}

.app-panel-close:hover { color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.app-panel-close:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.app-panel .screens { margin-bottom: 28px; }

.app-panel-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.app-panel-actions .btn-ghost:hover { border-color: var(--accent); }

/* status chip, on a card and on a per-app page */
.app-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: var(--surface);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px var(--line);
  padding: 10px 18px;
}

.app-status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  flex: none;
}

/* status chip and the live link share a row on a per-app page */
.app-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* carries the app's own accent, so the button belongs to the app not the site */
.btn-live { background: var(--accent); color: #fff; }
.btn-live:hover { filter: brightness(1.15); transform: translateY(-1px); }

/* ---------- app showcases (per-app pages) ---------- */

.back-link {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 28px;
  transition: color 0.15s ease;
}

.back-link:hover { color: var(--red); }

.showcase-head {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 18px;
}

.showcase-head .icon { width: 84px; height: 84px; border-radius: 20px; box-shadow: var(--shadow-sm); }

/* h1 on a per-app page, where the app name is the page's own heading */
.showcase-head h1, .showcase-head h2 {
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  font-weight: 700;
  letter-spacing: -0.025em;
}

.showcase-head .app-kind {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.fine-print {
  max-width: 46em;
  margin-top: 26px;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.app-showcase > .container > p.desc {
  max-width: 46em;
  color: var(--ink-soft);
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.feature-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 22px 0 40px;
}

.feature-list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.screens {
  display: flex;
  gap: 32px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.screens .phone { width: 250px; flex-shrink: 0; }

.screens figcaption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-faint);
  margin-top: 14px;
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .hero .container { grid-template-columns: 1fr; }

  .hero { padding-top: 40px; }

  .hero-phones {
    height: auto;
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 16px;
  }

  .hero-phones .phone { position: static; width: 200px; }
  .hero-phones .phone:nth-child(1) { transform: rotate(-4deg) translateY(20px); }
  .hero-phones .phone:nth-child(2) { transform: rotate(3deg); }

  .app-cards, .about .container { grid-template-columns: 1fr; }

  .value-grid { grid-template-columns: 1fr 1fr; }

  .contact { padding: 40px 28px; }
}

@media (max-width: 680px) {
  .site-nav {
    position: fixed;
    inset: 72px 0 auto 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 24px 28px;
    gap: 18px;
    box-shadow: var(--shadow-lg);
    transform: translateY(-130%);
    transition: transform 0.25s ease;
  }

  .nav-open .site-nav { transform: translateY(0); }

  .site-nav a { font-size: 1.05rem; }

  .nav-toggle { display: flex; }

  section { padding: 52px 0; }

  .value-grid { grid-template-columns: 1fr; gap: 26px; }

  .screens { gap: 22px; }
  .screens .phone { width: min(250px, 72vw); }

  .hero-phones .phone { width: 42vw; max-width: 200px; }
}
