/* ==========================================================================
   layout.css — app shell, screens, topbar, start & glasart screens,
   price-class selector, price toggle. Responsive: desktop / iPad / iPhone.
   ========================================================================== */

#app { height: 100%; }

/* ---- Screens ---- */
.screen { display: none; height: 100%; flex-direction: column; }
.screen.is-active { display: flex; }

/* ---- Boot states ---- */
.boot-loading, .boot-error {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 40px; color: var(--text-muted);
}
.boot-error { color: var(--coral); gap: 10px; }
.boot-error__hint { color: var(--text-muted); font-size: 0.85rem; max-width: 460px; }
.boot-error code { background: var(--cream-2); padding: 2px 6px; border-radius: 6px; }

/* ---- Brand wordmark on start screen ---- */
.start__brand {
  position: absolute; top: calc(22px + var(--safe-top, 0px)); left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans); font-weight: 700;
  letter-spacing: 0.42em; font-size: 0.92rem;
  color: rgba(255,255,255,0.82); text-indent: 0.42em;
  z-index: 2;
}

/* ============================ TOP BAR ============================ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  padding: 10px clamp(14px, 3vw, 28px);
  padding-top: calc(10px + var(--safe-top, 0px));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}
.topbar__tabs { display: flex; gap: 8px; }
.tab {
  padding: 9px 20px; border-radius: var(--r-pill);
  font-size: 0.86rem; font-weight: 600;
  background: var(--cream-2); color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.tab.is-active { background: var(--navy); color: var(--text-on-dark); }
.tab:disabled { opacity: 0.5; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
/* "Neue Beratung" — a secondary action, so a soft pill instead of the navy
   circles; with label where there is room (see RESPONSIVE). */
.topbar__restart {
  height: 44px; padding: 0 16px 0 13px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--r-pill);
  background: var(--cream-2); color: var(--text);
  font-size: 0.82rem; font-weight: 600; white-space: nowrap;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease);
}
.topbar__restart:hover { background: var(--pill-muted-bg); }
.topbar__restart:active { transform: scale(0.96); }
.topbar__restart svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ============================ START SCREEN ============================ */
#screen-start {
  background:
    radial-gradient(120% 120% at 80% 110%, rgba(255,255,255,0.10), transparent 60%),
    var(--navy);
  align-items: center; justify-content: center;
  text-align: center; color: var(--text-on-dark);
  position: relative; overflow: hidden;
}
.start__inner { padding: 40px; max-width: 760px; z-index: 1; }
.start__eyebrow { font-family: var(--font-serif); font-size: 1.4rem; font-style: italic; opacity: 0.8; margin-bottom: 6px; }
.start__title {
  font-family: var(--font-serif);
  font-size: var(--fs-display); font-weight: 600;
  margin-bottom: 38px; line-height: 1.1;
}
.start__lens { margin: 0 auto 34px; width: clamp(120px, 22vw, 190px); opacity: 0.9; }
#screen-start .deco-lens {
  position: absolute; bottom: -8%; left: 50%; transform: translateX(-50%);
  width: min(70vw, 620px); opacity: 0.12; pointer-events: none;
}

/* ============================ GLASART SCREEN ============================ */
.page {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: clamp(24px, 4vw, 56px) clamp(16px, 4vw, 40px) 60px;
}
.step-head {
  display: flex; align-items: center; gap: 16px; justify-content: center;
  margin-bottom: clamp(28px, 5vw, 52px);
}
.step-head__num {
  width: 44px; height: 44px; flex-shrink: 0;
  background: #9db8d0; color: var(--navy);   /* navy on light blue: readable in both themes */
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 1.3rem;
  /* Optical centering: Playfair's font box is ascent-heavy, so the digit ink
     lands ~0.17em below the circle centre. Bottom padding shifts the
     flex-centred glyph up by half its value; em-based → holds for the
     smaller mobile circle too. Horizontally the glyphs centre fine. */
  padding-bottom: 0.34em;
}
.step-head__title { font-family: var(--font-serif); font-size: var(--fs-h2); color: var(--text); }
.step-head__glasart {
  align-self: center;
  background: var(--navy); color: var(--white);
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  padding: 5px 13px; border-radius: var(--r-pill);
}

/* four glasarten as 2×2: clear lenses on top, sun lenses below */
.glasart-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(2, 1fr);
  max-width: 640px; margin: 0 auto;
}
.glasart-card {
  background: var(--cream-2);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  padding: 30px 22px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  text-align: center;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-fast);
}
.glasart-card:not(.is-disabled):hover { background: var(--surface); border-color: var(--text); }
.glasart-card:not(.is-disabled):active { transform: scale(0.98); }
.glasart-card.is-disabled { opacity: 0.5; }
.glasart-card__icon { color: var(--text); height: 46px; display: flex; align-items: center; }
.glasart-card__icon svg { height: 40px; width: auto; }
.glasart-card__title { font-size: 1.05rem; color: var(--text); }
.glasart-card__next {
  margin-top: auto;
  width: 100%; padding: 11px 14px; border-radius: var(--r-pill);
  background: var(--pill-muted-bg); color: var(--text-muted);
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--t-base), color var(--t-base);
}
.glasart-card__next svg { width: 15px; height: 15px; flex-shrink: 0; }
.glasart-card:not(.is-disabled):hover .glasart-card__next { background: var(--navy); color: var(--white); }
.glasart-card__soon {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
}

/* ---- Frame of the consultation (own frame / new frame + its price) ---- */
.frame-box {
  /* as wide as the glasart tiles above it (.glasart-grid, also per breakpoint) */
  max-width: 640px; margin: clamp(26px, 4vw, 40px) auto 0;
  background: var(--cream-2); border: 1.5px solid var(--border-soft);
  border-radius: var(--r-md); padding: 18px 22px;
}
/* center, not baseline: the title's icon would push its baseline down and
   the hint next to it would sit visibly lower */
.frame-box__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-bottom: 14px; }
.frame-box__title {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text);
}
.frame-box__title svg { width: 16px; height: 16px; }
.frame-box__hint { font-size: 0.78rem; color: var(--text-body); }
.frame-box__row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 20px; }
.frame-box__note {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; line-height: 1.4; color: var(--text-body);
}
.frame-box__note svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--text-body); }

.segmented {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--pill-muted-bg); border-radius: var(--r-pill);
}
.segmented__opt {
  /* min-height: iPad touch target */
  min-height: 44px; padding: 8px 18px; border-radius: var(--r-pill);
  font-size: 0.82rem; font-weight: 600; color: var(--text-body);
  transition: background var(--t-fast), color var(--t-fast);
}
/* the selected pill must read clearly in BOTH themes — navy on the muted
   track is invisible in dark, so it gets the lighter brand tone + outline */
.segmented__opt.is-sel { background: var(--navy); color: var(--white); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .segmented__opt.is-sel {
  background: var(--navy-light); color: var(--white);
  box-shadow: inset 0 0 0 1.5px var(--text);
}

.frame-field { display: flex; align-items: center; gap: 10px; }
.frame-field__label { font-size: 0.82rem; font-weight: 600; color: var(--text-body); }
.frame-field__input {
  display: inline-flex; align-items: center; gap: 4px;
  /* an input must read as an input: border ≥3:1 against the box in both themes */
  background: var(--surface); border: 1.5px solid var(--text-body); border-radius: var(--r-sm);
  padding: 8px 12px;
}
.frame-field__input:focus-within { border-color: var(--text); }
.frame-field__input input {
  width: 6.5ch; border: none; background: none; padding: 0;
  font: inherit; font-size: 0.95rem; font-weight: 700; color: var(--text); text-align: right;
  appearance: textfield; -moz-appearance: textfield;
}
.frame-field__input input:focus { outline: none; }
.frame-field__input input::-webkit-outer-spin-button,
.frame-field__input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.frame-field__cur { font-size: 0.9rem; font-weight: 700; color: var(--text-body); }

/* ============================ EINSTIEG SCREEN ============================ */
/* Intermediate step (feature toggle in /bmin): pick the entry price class.
   Cards mirror the glasart cards; the bestseller badge floats like on the
   class bar. */
.entry-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(5, 1fr);
  max-width: var(--maxw); margin: 0 auto;
  padding-top: 11px;   /* room for the floating bestseller badge */
}
.entry-card {
  position: relative;
  background: var(--cream-2);
  border: 2px solid transparent;
  border-radius: var(--r-md);
  padding: 24px 16px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-align: center;
  transition: background var(--t-base), border-color var(--t-base), transform var(--t-fast);
}
.entry-card:hover { background: var(--surface); border-color: var(--text); }
.entry-card:active { transform: scale(0.98); }
.entry-card.is-active { background: var(--surface); border-color: var(--text); box-shadow: var(--shadow); }
.entry-card__star { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); }
.entry-card__name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.entry-card__sub { font-size: 0.76rem; color: var(--text-muted); }
/* Sehbereiche illustration: its own button above the stretched CTA (see
   .entry-card__cta::after) — a tap opens it full screen. Fixed ratio +
   contain keeps all five cards the same height and never crops it. */
.entry-card__zoom {
  position: relative; z-index: 1;
  display: block; width: 100%; margin-top: 12px;
  border-radius: var(--r-sm); cursor: zoom-in;
}
.entry-card__img {
  width: 100%; height: auto;
  aspect-ratio: 4 / 3; object-fit: contain;
  border-radius: var(--r-sm); background: var(--white);
}
.entry-card__zoom-hint {
  position: absolute; right: 6px; bottom: 6px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(17, 40, 64, 0.78); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.entry-card__zoom-hint svg { width: 14px; height: 14px; }
.entry-card__zoom:hover .entry-card__zoom-hint { background: var(--navy); }
.entry-card__from { margin-top: 14px; font-family: var(--font-serif); font-size: 1.3rem; color: var(--text); }
.entry-card__from .from {
  font-family: var(--font-sans); font-size: 0.78rem; color: var(--text-muted); margin-right: 2px;
}
.entry-card__cta {
  margin-top: 16px;
  width: 100%; padding: 10px 12px; border-radius: var(--r-pill);
  background: var(--pill-muted-bg); color: var(--text-muted);
  font-size: 0.76rem; font-weight: 600; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--t-base), color var(--t-base);
}
.entry-card__cta svg { width: 14px; height: 14px; flex-shrink: 0; }
/* the whole card selects the class: the CTA's hit area covers it */
.entry-card__cta::after { content: ""; position: absolute; inset: 0; border-radius: var(--r-md); }
.entry-card:hover .entry-card__cta { background: var(--navy); color: var(--white); }
/* …except the artwork, which zooms — don't announce "select" over it.
   Separate rules: a browser without :has() just keeps the plain hover. */
.entry-card:has(.entry-card__zoom:hover) .entry-card__cta { background: var(--pill-muted-bg); color: var(--text-muted); }
.entry-card:has(.entry-card__zoom:active) { transform: none; }
.entry-hint {
  text-align: center; margin-top: 20px;
  font-size: 0.78rem; color: var(--text-muted);
}

/* ============================ GLÄSER SCREEN ============================ */
#screen-glaeser .page { padding-bottom: 110px; }

/* ---- Price-class selector (horizontal) ---- */
.class-bar {
  display: flex; gap: 10px; justify-content: center; align-items: stretch;
  max-width: var(--maxw); margin: 0 auto clamp(26px, 4vw, 44px);
  flex-wrap: nowrap;
}
.class-card {
  flex: 1 1 0; min-width: 0;
  position: relative;
  border-radius: var(--r-md);
  padding: 16px 12px;
  background: transparent;
  border: 2px solid transparent;
  text-align: center;
  transition: background var(--t-base) var(--ease), box-shadow var(--t-base), transform var(--t-base), border-color var(--t-base);
}
.class-card:hover { background: rgba(255,255,255,0.55); }
.class-card.is-active {
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateY(-6px) scale(1.04);
  border-color: var(--border);
}
/* name and subtitle always stack — never inline behind the name */
.class-card__name { display: block; font-size: 1.02rem; font-weight: 700; color: var(--text); }
.class-card.is-active .class-card__name { font-size: 1.12rem; }
.class-card__sub { display: block; font-size: 0.74rem; color: var(--text-muted); margin-top: 3px; }
.class-card__star {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
}

/* ---- Lines & product groups ---- */
.lines { display: flex; flex-direction: column; gap: clamp(22px, 3vw, 34px); max-width: var(--maxw); margin: 0 auto; }
.line__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
/* "Kundennutzen Glas" of the line (inline mode) — one muted line under the head */
.line__benefits {
  margin: -6px 0 14px; max-width: 72ch;
  font-size: 0.82rem; line-height: 1.45; color: var(--text-body, var(--text));
}
.line__name {
  font-family: var(--font-serif); font-size: 1.25rem; color: var(--text);
}
.line__class {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted); align-self: center;
}
.line__ounda {
  align-self: center;
  font-size: 0.72rem; font-weight: 600; color: var(--apricot);
  background: var(--apricot-bg); border: 1px solid #f3e3c0;
  padding: 3px 10px; border-radius: var(--r-pill);
}
.glass-grid {
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(2, 1fr);
}

/* ---- Floating price-mode toggle ---- */
.price-toggle {
  position: fixed; z-index: 30;
  right: calc(20px + var(--safe-right, 0px));
  bottom: calc(20px + var(--safe-bottom, 0px));
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--navy); color: var(--white);
  padding: 10px 8px 10px 16px; border-radius: var(--r-pill);
  box-shadow: var(--shadow);
  font-size: 0.8rem; font-weight: 600;
}
.price-toggle__opt {
  padding: 6px 12px; border-radius: var(--r-pill);
  color: rgba(255,255,255,0.55);
  transition: background var(--t-fast), color var(--t-fast);
}
.price-toggle__opt.is-sel { background: rgba(255,255,255,0.18); color: var(--white); }

/* ====================================================================
   RESPONSIVE
   ==================================================================== */

/* Wide desktop: lines can place glass cards in 3 columns */
@media (min-width: 1024px) {
  .glass-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Top bar gets tight: "Neue Beratung" becomes a round icon button */
@media (max-width: 760px) {
  .topbar__restart { aspect-ratio: 1; padding: 0; }
  .topbar__restart-label { display: none; }
}

/* iPad portrait & small tablets */
@media (max-width: 820px) {
  .glasart-grid, .frame-box { max-width: 560px; }
  .entry-grid { grid-template-columns: repeat(2, 1fr); max-width: 560px; gap: 14px; }
}

/* Phones */
@media (max-width: 600px) {
  :root { --topbar-h: 56px; }
  .topbar { padding: 8px 14px; }
  .tab { padding: 8px 15px; font-size: 0.8rem; }
  .icon-btn { width: 40px; height: 40px; }
  .topbar__restart { height: 40px; }

  .glasart-grid { grid-template-columns: 1fr; gap: 12px; max-width: 420px; }
  .frame-box { max-width: 420px; }
  .glasart-card { flex-direction: row; padding: 16px; text-align: left; gap: 14px; }
  .glasart-card__icon { height: auto; flex-shrink: 0; }
  /* the glasart name stands right beside it — "Weiter →" is enough (and keeps
     "Einstärke Sonne" / "Gleitsicht Sonne" from squeezing the icon away) */
  .glasart-card__next-ga { display: none; }
  .glasart-card__title { flex: 1; }
  .glasart-card__next { width: auto; margin-top: 0; }

  /* entry cards become compact rows: name/sub left, price right */
  .entry-grid { grid-template-columns: 1fr; gap: 10px; max-width: 420px; padding-top: 0; }
  .entry-card {
    display: grid; align-items: center; text-align: left;
    grid-template-areas: "star star" "name from" "sub from" "img img" "cta cta";
    grid-template-columns: 1fr auto;
    gap: 1px 14px;
    padding: 14px 16px 12px;
  }
  .entry-card__star { grid-area: star; position: static; transform: none; justify-self: start; margin-bottom: 5px; }
  .entry-card__name { grid-area: name; }
  .entry-card__sub { grid-area: sub; }
  .entry-card__zoom { grid-area: img; margin-top: 10px; }
  .entry-card__from { grid-area: from; margin-top: 0; justify-self: end; }
  .entry-card__cta { grid-area: cta; margin-top: 10px; }

  /* class selector becomes a horizontal scroller of pills */
  .class-bar {
    flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start;
    gap: 8px; padding: 8px 2px 14px; margin-bottom: 18px;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none; scrollbar-width: none;
  }
  .class-bar::-webkit-scrollbar { display: none; }
  .class-card {
    flex: 0 0 auto; scroll-snap-align: center;
    padding: 10px 16px; border-radius: var(--r-pill);
    background: var(--surface); box-shadow: var(--shadow-sm);
  }
  .class-card.is-active { transform: none; background: var(--navy); }
  .class-card.is-active .class-card__name,
  .class-card.is-active .class-card__sub { color: var(--white); }
  .class-card__sub { display: none; }
  .class-card.is-active .class-card__sub { display: block; opacity: 0.8; }
  .class-card__star { display: none; }

  .glass-grid { grid-template-columns: 1fr; }
  .step-head__num { width: 38px; height: 38px; }
}

/* Small phones: tabs + four actions don't fit one row (~515px) → actions on
   top ("Neue Beratung" with label left, icons right), tabs full width below */
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar__actions { order: -1; flex: 1 0 100%; }
  .topbar__restart { aspect-ratio: auto; padding: 0 14px 0 11px; margin-right: auto; }
  .topbar__restart-label { display: inline; }
  .topbar__tabs { flex: 1 0 100%; }
  .topbar__tabs .tab { flex: 1; padding: 8px 6px; }
}
