/* ==========================================================================
   GlucoRead landing page.

   Tokens, buttons, topbar, segmented controls and form fields come from
   main/css/theme.css. This file is the page itself: hero, dashboard preview,
   the how-it-works steps, the feature grid, the closer and the footer.
   ========================================================================== */

main,
.site-footer {
  position: relative;
  z-index: 1;
}

/* --------------------------------- hero ---------------------------------- */
.hero {
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(3.5rem, 8vw, 6rem);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(2.5rem, 5vw, 3.5rem);
  align-items: center;
}

@media (min-width: 1000px) {
  .hero-grid {
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.18fr);
    gap: clamp(2.5rem, 5vw, 4rem);
  }
}

/* sized so the headline holds at two lines from 360px up to the max width */
.hero-title {
  font-size: clamp(2.25rem, 4.1vw, 3.15rem);
  line-height: 1.04;
  letter-spacing: -0.035em;
  max-width: 19ch;
}

.hero-lead {
  margin-top: 1.35rem;
  max-width: 46ch;
  font-size: clamp(1.05rem, 1.5vw, 1.15rem);
  color: var(--ink-2);
}

.hero-copy .actions {
  margin-top: 2rem;
}

/* hero entrance: one short cascade, top to bottom */
.hero-title,
.hero-lead,
.hero-copy .actions,
.app-preview {
  animation: rise 0.8s var(--ease) both;
}

.hero-lead {
  animation-delay: 0.08s;
}

.hero-copy .actions {
  animation-delay: 0.16s;
}

.app-preview {
  animation-delay: 0.12s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

/* --------------------------- dashboard preview ---------------------------- */
.app-preview {
  margin: 0;
}

.app-window {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.app-rail {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1.1rem 0.75rem;
  background: var(--paper-2);
  border-right: 1px solid var(--line-soft);
  font-size: 0.88rem;
}

.app-rail-item {
  padding: 0.5rem 0.7rem;
  border-radius: var(--r-md);
  color: var(--ink-2);
}

.app-rail-item.is-active {
  color: var(--accent-ink);
  background: var(--accent);
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--line-soft);
}

.app-top-title {
  font-weight: 600;
  letter-spacing: -0.015em;
}

.app-account {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-2);
}

.app-avatar {
  width: 22px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--paper-2);
  border: 1px solid var(--line);
}

.app-panel {
  padding: 1.15rem;
}

.app-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.app-panel-title {
  font-size: 1.02rem;
}

.app-panel-date {
  margin-top: 0.15rem;
  font-size: 0.82rem;
  color: var(--ink-3);
}

.app-trend-controls {
  display: flex;
  gap: 0.35rem;
  font-size: 0.78rem;
}

.app-trend-controls span {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--ink-2);
}

.app-trend-controls span.is-disabled {
  opacity: 0.45;
}

.app-chart {
  position: relative;
  height: 232px;
}

.app-preview figcaption {
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: var(--ink-3);
  text-align: center;
}

/* ------------------------------- sections -------------------------------- */
.section {
  padding-block: clamp(4rem, 9vw, 7rem);
}

.grid-head {
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  max-width: 20ch;
  margin-bottom: clamp(2.25rem, 4vw, 3.25rem);
}

/* how it works: sticky heading beside a stepped list */
.how-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(2rem, 4vw, 3rem);
}

@media (min-width: 900px) {
  .how-grid {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    gap: clamp(3rem, 6vw, 5rem);
  }

  .how-head {
    position: sticky;
    top: 7rem;
    align-self: start;
  }
}

.how-head h2 {
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  max-width: 14ch;
}

.how-head p {
  margin-top: 1rem;
  color: var(--ink-2);
  max-width: 30ch;
}

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

.how-step {
  padding-block: clamp(1.75rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line-soft);
}

.how-step:first-child {
  padding-top: 0;
}

.how-step:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.how-step h3 {
  font-size: 1.32rem;
}

.how-step p {
  margin-top: 0.55rem;
  color: var(--ink-2);
  max-width: 48ch;
}

/* ---------------------------- app UI previews ----------------------------- */
/* Same labels, fields and controls as the real screens, drawn in the page's
   own palette. Static by design: these are illustrations, not live forms. */
.ui-preview {
  margin-top: 1.4rem;
  padding: 1rem 1.1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  font-size: 0.9rem;
}

.ui-heading {
  font-weight: 600;
  font-size: 0.95rem;
}

.ui-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.85rem;
}

.ui-label {
  font-size: 0.8rem;
  color: var(--ink-2);
}

.ui-input {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.ui-input.is-empty {
  color: var(--ink-3);
  font-family: var(--font-sans);
}

.ui-input.is-select {
  font-family: var(--font-sans);
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: right 1rem center, right 0.72rem center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.ui-btn {
  display: inline-block;
  margin-top: 1.1rem;
  padding: 0.45rem 1.1rem;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.86rem;
  font-weight: 500;
}

/* today's cards */
.ui-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  padding: 0.75rem;
}

.ui-metric {
  display: flex;
  flex-direction: column;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--paper);
}

.ui-metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--ink-2);
}

.ui-metric-head em {
  font-style: normal;
  font-size: 0.68rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--r-pill);
  color: var(--range);
  background: var(--range-soft);
}

.ui-metric-value {
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.ui-metric-sub {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--ink-3);
}

/* trend panel header */
.ui-trend-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ui-trend-date {
  font-size: 0.82rem;
  color: var(--ink-3);
}

.ui-trend-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.9rem;
  font-size: 0.8rem;
}

.ui-trend-controls span {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--ink-2);
}

/* recent activity feed */
.ui-activity ul {
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
}

.ui-activity li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.55rem;
  border-top: 1px solid var(--line-soft);
  color: var(--ink-2);
}

.ui-time {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-3);
}

/* --------------------------------- bento --------------------------------- */
.bento {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(0.85rem, 1.6vw, 1.15rem);
}

@media (min-width: 640px) {
  .bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cell-timeline,
  .cell-units,
  .cell-private {
    grid-column: span 2;
  }
}

@media (min-width: 1024px) {
  .bento {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .cell-timeline {
    grid-column: span 7;
  }

  .cell-units {
    grid-column: span 5;
  }

  .cell-safe {
    grid-column: span 3;
  }

  .cell-week {
    grid-column: span 4;
  }

  .cell-private {
    grid-column: span 5;
  }
}

.cell {
  display: flex;
  flex-direction: column;
  padding: clamp(1.25rem, 2.2vw, 1.75rem);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  transition: transform 0.35s var(--ease), border-color 0.35s var(--ease);
}

.cell:hover {
  transform: translateY(-3px);
  border-color: var(--line);
}

.cell h3 {
  font-size: 1.16rem;
}

.cell p {
  margin-top: 0.5rem;
  color: var(--ink-2);
  font-size: 0.96rem;
  max-width: 42ch;
}

.cell-units {
  background: linear-gradient(160deg, var(--accent-soft), transparent 62%), var(--surface);
}

.cell-week {
  background: linear-gradient(180deg, transparent 40%, var(--range-soft)), var(--surface);
}

.cell-timeline .ui-preview {
  margin-top: auto;
  padding: 0.9rem 0 0;
  background: transparent;
  border: 0;
}

.spark {
  width: 100%;
  height: 72px;
  margin-top: auto;
  padding-top: 1.5rem;
  overflow: visible;
}

.spark-band {
  fill: var(--range-soft);
}

.spark-line {
  fill: none;
  stroke: var(--range);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.reveal.show .spark-line {
  animation: draw 1.4s var(--ease) 0.15s both;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* unit switch: the conversion is the feature, so let people try it */
.unit-toggle {
  margin-top: 1.4rem;
  align-self: flex-start;
}

.unit-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem;
  margin: 1.5rem 0 0;
}

.unit-demo dt {
  font-size: 0.78rem;
  color: var(--ink-3);
}

.unit-demo dd {
  margin: 0.15rem 0 0;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.unit-value.is-swapping {
  animation: swap 0.32s var(--ease);
}

@keyframes swap {
  50% {
    opacity: 0;
    transform: translateY(-6px);
  }
  51% {
    transform: translateY(6px);
  }
}

/* -------------------------------- closer --------------------------------- */
.closer {
  padding-block: clamp(4rem, 9vw, 7rem);
  border-top: 1px solid var(--line-soft);
  background: linear-gradient(180deg, transparent, var(--accent-soft));
}

.closer-inner {
  text-align: center;
}

.closer h2 {
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  margin-inline: auto;
}

.closer p {
  margin-top: 0.9rem;
  color: var(--ink-2);
}

.closer .actions {
  margin-top: 1.9rem;
  justify-content: center;
}

/* -------------------------------- footer --------------------------------- */
.site-footer {
  border-top: 1px solid var(--line-soft);
  padding-block: 2.5rem;
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 2rem;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
  color: var(--ink-2);
}

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

.footer-disclaimer {
  flex: 1 1 100%;
  color: var(--ink-3);
  font-size: 0.82rem;
  max-width: 62ch;
}

/* ------------------------------- reveals --------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
}

.reveal.show {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease) var(--d, 0ms), transform 0.7s var(--ease) var(--d, 0ms);
}

/* ------------------------------- responsive ------------------------------ */
@media (max-width: 720px) {
  .app-window {
    grid-template-columns: minmax(0, 1fr);
  }

  /* the sidebar becomes a row of links, the way a narrow app would show it */
  .app-rail {
    flex-direction: row;
    gap: 0.35rem;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding: 0.6rem;
  }

  .app-rail-item {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
  }

  .app-chart {
    height: 200px;
  }
}

@media (max-width: 520px) {
  .actions .btn {
    flex: 1 1 100%;
  }

  .unit-demo {
    gap: 1.25rem;
  }
}

/* ----------------------------- reduced motion ---------------------------- */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
  }

  .spark-line {
    stroke-dashoffset: 0;
  }
}
