/*
 * The public page (live.talia-app.com) and the talia-app.com embed. The wall card
 * and chips come from wall.css, the picker and thank-you card from app.css; this
 * file lays them out. On a computer (wide screen, mouse or trackpad) the wall sits
 * beside a QR code for adding symptoms by phone. On phones and tablets a button
 * opens the symptom card in place.
 */
:root { --sand: #e0dad2; --aubergine-solid: #442345; }

html, body.site { height: auto; min-height: 100%; }
body.site {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: #fff;
  background: var(--dusky-pink);
  cursor: auto;
  overflow-x: hidden;
}
.site-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--dusky-pink) url("../img/bg-wall.jpg") center / cover no-repeat;
}

/* ---------- Header and footer ---------- */
.site-header, .site-main, .site-footer { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; }
/* TALIA centred, with the tagline under it, as on the thank-you card. */
.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 14px;
  text-align: center;
}
.site-header .brand img { display: block; width: auto; height: 34px; }
/* The language chips sit in the top right corner, or under the tagline on a phone. */
.site-header .lang-chips { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 18px); right: 16px; justify-content: flex-end; }
@media (max-width: 599px) {
  .site-header .lang-chips { position: static; margin-top: 6px; justify-content: center; }
}
.brand-tag { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.site-footer { padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 28px); text-align: center; font-size: 13px; opacity: 0.9; }
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: #fff; }

/* ---------- Layout ---------- */
.site-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 0 16px 16px; }
.wall-col, .side-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.add-col { min-width: 0; scroll-margin-top: 12px; }
/* From 860px (a computer, or a tablet on its side) the wall takes the full width and everything
   else sits in two columns under it: the QR code (or the Add button, or the open card) on the left,
   the co-brand and Top 5 on the right. The public page and the talia-app.com frame share this. */
@media (min-width: 860px) {
  /* Row 2 takes any extra height from the tall left cell, so Top 5 stays right under the co-brand. */
  .side-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 16px; align-items: start; }
  .side-col > .add-btn, .side-col > .scan-block, .side-col > .add-col { grid-column: 1; grid-row: 1 / span 2; }
  .side-col > .cobrand, .side-col > .months { grid-column: 2; }
}

/* ---------- Scan to add, on a computer (under the wall) ---------- */
.scan-block {
  display: none;
  padding: 14px;
  border-radius: 22px;
  background: rgba(68, 35, 69, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.scan-block .qr-card { background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16); }
.scan-block .qr-card img { display: block; width: 100%; height: auto; }
.scan-caption { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; }
.scan-url { margin: 4px 0 0; font-size: 13px; }
/* A mouse or trackpad: the QR code in a compact row with the Add Symptoms button. Phones and
   tablets get the Add button under the wall instead. */
@media (hover: hover) and (pointer: fine) {
  .scan-block {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    column-gap: 16px;
    align-items: start;
    text-align: left;
  }
  .scan-block .qr-card { grid-row: 1 / span 4; width: 116px; padding: 8px; border-radius: 12px; }
  .scan-block .scan-caption { margin-top: 4px; font-size: 16px; }
  .scan-block .add-here { justify-self: start; }
  .add-btn { display: none; }
}
@media (min-width: 860px) and (hover: hover) and (pointer: fine) {
  .scan-block { grid-template-columns: 132px minmax(0, 1fr); column-gap: 18px; padding: 14px 16px; }
  .scan-block .qr-card { width: 132px; }
  .scan-block .scan-caption { margin-top: 8px; font-size: 17px; }
}
/* "or", then the Add Symptoms button: the two ways in, side by side in people's minds. */
.scan-or { margin: 10px 0 0; font-size: 13px; opacity: 0.85; }
.scan-block .add-here { display: inline-block; width: auto; margin: 8px 0 0; padding: 10px 22px; border: 0; font: 600 15px/1.2 var(--font); cursor: pointer; }
.scan-block .add-here:hover { filter: brightness(1.08); }
.add-here:focus-visible, .done .link:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }

/* ---------- The wall card on the web ---------- */
.card.web {
  flex: 0 0 auto;
  height: clamp(470px, 132vw, 640px);
  height: clamp(420px, min(132vw, calc(100svh - 140px)), 640px); /* small phones: leave room for the button */
  padding: 16px 16px 12px;
  border-radius: 22px;
  scroll-margin-top: 12px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
@media (min-width: 600px) { .card.web { height: 580px; padding: 20px 22px 14px; } }
@media (min-width: 1000px) { .card.web { height: min(72vh, 680px); min-height: 520px; } }
.card.web .card-title {
  margin: 0 0 4px;
  font-size: clamp(15px, 1.1vw + 11px, 23px);
  letter-spacing: 0.09em;
  line-height: 1.3;
}
.card.web .title-live { letter-spacing: 0.02em; white-space: nowrap; }
.card-intro { margin: 0 0 10px; font-size: 13px; line-height: 1.35; opacity: 0.88; }
/* Short phones (an iPhone SE): the intro line gives its room to the chips, unless it is saying the wall started from research. */
@media (max-width: 599px) and (max-height: 620px) { .card.web .card-intro:not(.from-research) { display: none; } }
.intro-sources { color: #fff; font-weight: 600; white-space: nowrap; }
.intro-sources:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; border-radius: 2px; }
.card.web .card-note, .card.web .card-countries { font-size: 13px; margin-top: 6px; }

/* Every range in view at any width: the chips wrap (two rows on a phone) rather than
   scroll sideways (nothing hints at a sideways scroll with a mouse). */
.age-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; padding: 2px 0 4px; }
.age-chip {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: 600 13px/1.1 var(--font);
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.age-chip:hover { background: rgba(255, 255, 255, 0.2); }
.age-chip:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }
.age-chip.on { background: var(--sand); border-color: var(--sand); color: var(--aubergine-solid); }
.age-chip.few:not(.on) { opacity: 0.55; }
@media (max-width: 599px) {
  .age-chips { gap: 5px; margin-bottom: 6px; }
  .age-chip { padding: 6px 10px; font-size: 12.5px; }
}

.add-btn { margin: 0; border: 0; font-family: inherit; cursor: pointer; }
.add-btn:focus-visible { outline: 2px solid var(--sand); outline-offset: 3px; }

/* ---------- Co-brand, web sizes (wall.css sizes it for a TV) ---------- */
.site .cobrand {
  margin: 0;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.site .cobrand-label { margin: 0 0 8px; font-size: 13px; }
.site .cobrand-mark.panel { padding: 10px; border-radius: 12px; }
.site .cobrand-logo { max-height: 56px; }
.site .cobrand-name { font-size: 20px; }
.site .cobrand-text { margin-top: 8px; font-size: 14px; }

/* ---------- Top 5 by month ---------- */
.months {
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  scroll-margin-top: 12px;
}
.months-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 18px;
  border: 0;
  background: none;
  color: #fff;
  font: 600 15px/1.2 var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}
.months-toggle svg { transition: transform 0.25s ease; }
.months.open .months-toggle svg { transform: rotate(180deg); }
.months-toggle:focus-visible { outline: 2px solid var(--sand); outline-offset: -4px; border-radius: 22px; }
.months-body { padding: 0 18px 16px; }
.month + .month { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.14); }
.month-name { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.so-far { font-weight: 400; opacity: 0.8; }
.top5 { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: rank; }
.month-chip {
  counter-increment: rank;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(86, 41, 56, 0.35);
  font-size: 14px;
}
.month-chip::before { content: counter(rank) "  "; font-weight: 700; color: var(--sand); white-space: pre; }
.months .few { margin: 0; font-size: 14px; opacity: 0.85; }

/* ---------- The picker and thank-you card inline on the page ---------- */
.sheet.inline {
  margin: 0;
  max-width: none;
  min-height: 0;
  border-radius: 16px;
  overflow: visible; /* keeps the top bar sticky while the page scrolls */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  color: var(--label);
}
.sheet.inline::before { display: none; }
.sheet.inline .navbar { top: 0; border-radius: 16px 16px 0 0; padding-top: 12px; }
.sheet.inline .list { padding-bottom: 20px; }
.clear-row { margin: 10px 0 0; text-align: center; }
.clear-row .link { color: var(--accent); opacity: 1; }
.done .link { opacity: 1; }
@media (min-width: 860px) {
  .sheet.inline { max-width: none; max-height: calc(100vh - 32px); overflow: auto; overscroll-behavior: contain; }
}
/* Where the card scrolls inside itself, a scrollbar that is always shown (a mouse plugged in)
   is drawn square over the rounded corners: border-radius does not clip it. clip-path does,
   but clips the shadow too, so the column round the card carries the shadow instead (only
   where :has() works, so an older browser keeps the card's own shadow). */
@supports selector(:has(*)) {
  @media (min-width: 860px) {
    .sheet.inline { box-shadow: none; clip-path: inset(0 round 16px); }
    .add-col:has(> .sheet.inline:not([hidden])) { border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
  }
}
.done.inline { min-height: 0; padding: 0; display: block; }
.done.inline .done-card { max-width: none; }
.done.inline .done-title { margin-top: 2px; }
.done-title:focus { outline: none; }

/* ---------- The talia-app.com embed ---------- */
body.embed { height: 100vh; overflow: hidden; display: flex; flex-direction: column; gap: 10px; padding: 10px; box-sizing: border-box; }
body.embed .card.web { flex: 1 1 auto; height: auto; min-height: 0; position: relative; z-index: 1; }
.embed-actions { position: relative; z-index: 1; display: flex; gap: 8px; }
.embed-actions .btn { flex: 1 1 0; margin: 0; padding: 12px 8px; font-size: 14px; white-space: nowrap; }
@media (max-width: 520px) { body.embed .card-intro:not(.from-research) { display: none; } }
body.embed .cobrand { position: relative; z-index: 1; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px; }
body.embed .cobrand-label, body.embed .cobrand-text { margin: 0; font-size: 12px; }
body.embed .cobrand-mark { width: auto; }
body.embed .cobrand-logo { max-height: 32px; }

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

/* ---------- The full Global page inside the talia-app.com frame (/embed?fit=auto) ----------
   The frame is sized to this page by the host, so its viewport is the page itself: nothing
   here may be sized from vh/svh (it would feed back into the frame's own height): the card and
   the symptom list get fixed heights instead. The layout itself is the public page's. */
html.in-frame, html.in-frame body.embed-fluid { height: auto; min-height: 0; } /* never at least the frame's own height */
.embed-fluid .site-main { max-width: none; padding: 16px; }
.embed-fluid .card.web { height: clamp(470px, 132vw, 640px); min-height: 0; }
.embed-fluid .sheet.inline { max-height: none; overflow: visible; }
@media (min-width: 600px) { .embed-fluid .card.web { height: 560px; } }
@media (min-width: 860px) {
  .embed-fluid .card.web { height: 620px; }
  .embed-fluid .sheet.inline { max-height: 600px; overflow: auto; overscroll-behavior: contain; }
}
