/*
 * Lumio Web-App.
 *
 * The look is taken straight from the real app's design system
 * (app/lib/core/theme/app_theme.dart) so this reads as Lumio on a smaller
 * plate, not as a different product: warm terracotta, sage and honey on cream,
 * flat cards at radius 24 with no shadow (the app's GlassCard), Inter for the
 * interface and Pacifico for the wordmark.
 *
 * Light and dark both ship, because the app has both and a phone that is set to
 * dark should not get a blazing cream screen at night.
 */

:root {
  /* --- brand, straight from app_theme.dart --- */
  --terra: #cc7351;          /* seed / primary   */
  --terra-deep: #b35c3d;
  --sage: #7c9473;           /* secondary        */
  --honey: #e0a458;          /* tertiary         */

  /* light surfaces */
  --bg: #fbf4ec;             /* creamSurface     */
  --card: #fffbf6;           /* creamCard        */
  --raised: #f3e9dd;         /* surfaceContainerHighest */
  --ink: #3b2e25;            /* warmInk          */
  --ink-soft: #8a7a6b;       /* warmInkSoft      */
  --line: #e6d8c8;           /* outlineVariant   */
  --field: #f3e9dd;

  --hero-1: #fceee1;         /* heroGradient     */
  --hero-2: #f4e7d6;
  --warm-1: #f7e0ce;         /* warmGradient     */
  --warm-2: #efe6d2;

  --on-terra: #ffffff;
  --shadow: 0 18px 46px -30px rgba(120, 70, 40, 0.5);

  /* mood scale, from mood_calendar.dart — deliberately desaturated */
  --mood-1: #d99aa0;
  --mood-2: #e4b08d;
  --mood-3: #e5c46d;
  --mood-4: #9bc49c;
  --mood-5: #7fb7ae;

  --radius: 24px;            /* AppTheme.radius      */
  --radius-sm: 16px;         /* AppTheme.radiusSmall */
  --pill: 999px;

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --brand: 'Pacifico', 'Brush Script MT', cursive;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --tabbar-h: 68px;          /* the app's nav bar height */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1613;           /* darkSurface */
    --card: #272019;         /* darkCard    */
    --raised: #2e271f;
    --ink: #f1e7dc;
    --ink-soft: #c9bbad;
    --line: #43392f;
    --field: #2c241d;

    --hero-1: #2e251d;
    --hero-2: #1b1613;
    --warm-1: #3a2a20;
    --warm-2: #2a2438;

    --shadow: 0 18px 46px -30px rgba(0, 0, 0, 0.7);
  }
}

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

/* Must outrank the display rules below: `hidden` works via the UA stylesheet's
   `display: none`, which any class setting grid/flex silently beats. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow: hidden;          /* the screens scroll, not the document */
}

/* The app's hero gradient, used as the ambient ground here too. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(160deg, var(--hero-1), var(--hero-2));
}

button, textarea, input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--terra); outline-offset: 3px; border-radius: 8px; }

/* =================================================================== marks */

.wordmark {
  font-family: var(--brand);
  font-weight: 400;
  color: var(--terra);
  line-height: 1.1;
}

.mark {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff 0%, var(--honey) 40%, var(--terra) 100%);
  box-shadow: 0 12px 30px -12px rgba(204, 115, 81, 0.75);
  margin-inline: auto;
}
.mark.sm { width: 22px; height: 22px; margin: 0; box-shadow: 0 6px 14px -6px rgba(204,115,81,.8); }

/* ==================================================================== gate */

.gate {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: max(2rem, env(safe-area-inset-top)) 1.4rem max(2rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  text-align: center;
}
.gate-inner { width: min(29rem, 100%); }

.gate h1 { margin-top: 1.1rem; font-size: 2.6rem; }
.tagline { font-size: 0.98rem; color: var(--ink-soft); margin-top: 0.35rem; }
.gate-lede { margin-top: 1.7rem; font-size: 0.97rem; color: var(--ink-soft); }

/* the "this is a limited build" notice — shown before anyone commits to it */
.notice {
  margin-top: 1.6rem;
  padding: 1.15rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--terra);
  border-radius: var(--radius-sm);
  text-align: left;
}
.notice h2 {
  font-size: 0.95rem; font-weight: 600; color: var(--ink);
  margin-bottom: 0.5rem;
}
.notice p { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.65; }
.notice p + p { margin-top: 0.6rem; }
.notice b { color: var(--terra-deep); font-weight: 600; }

.steps { list-style: none; margin-top: 1.6rem; display: grid; gap: 0.55rem; text-align: left; }
.steps li {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}
.steps .n {
  flex: none; width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--terra); color: var(--on-terra);
  display: grid; place-items: center;
  font-size: 0.74rem; font-weight: 600;
}
.steps b { font-weight: 600; }

/* the iOS share glyph, drawn rather than shipped as an image */
.ios-share {
  display: inline-block;
  width: 13px; height: 16px;
  margin: 0 1px -2px 2px;
  border: 1.6px solid var(--terra);
  border-top: 0;
  border-radius: 0 0 3px 3px;
  position: relative;
}
.ios-share::before {
  content: ''; position: absolute;
  left: 50%; top: -8px; translate: -50% 0;
  width: 1.6px; height: 9px; background: var(--terra);
}
.ios-share::after {
  content: ''; position: absolute;
  left: 50%; top: -8px; translate: -50% 0;
  width: 6px; height: 6px;
  border-left: 1.6px solid var(--terra);
  border-top: 1.6px solid var(--terra);
  rotate: 45deg;
}

.gate-foot { margin-top: 1.5rem; font-size: 0.82rem; color: var(--ink-soft); }

.gate-split { margin-top: 1.6rem; display: grid; gap: 0.65rem; text-align: left; }
.gate-col {
  padding: 1.15rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.gate-col h2 {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--terra-deep); margin-bottom: 0.5rem;
}
.gate-col p { font-size: 0.89rem; color: var(--ink-soft); }
.gate-col .btn { margin-top: 0.9rem; }

/* ================================================================= buttons */

/* The app's FilledButton: pill, 54px tall, weight 600. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px;
  padding: 0.75rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--pill);
  background: var(--terra);
  color: var(--on-terra);
  font-size: 0.95rem; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

/* ===================================================================== app */

.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 0.7rem;
  padding: calc(env(safe-area-inset-top) + 0.7rem) 1.15rem 0.5rem;
}
.topbar .wordmark { font-size: 1.35rem; }
.topbar-note {
  font-size: 0.66rem; font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--pill);
  background: var(--raised);
  color: var(--ink-soft);
}

.screens { flex: 1; min-height: 0; position: relative; }

.screen {
  position: absolute; inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 1.15rem calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1.4rem);
  display: none;
}
.screen.is-on { display: block; }

.screen-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.screen-lede { font-size: 0.92rem; color: var(--ink-soft); margin-top: 0.25rem; }
.sub { margin: 1.9rem 0 0.7rem; font-size: 1rem; font-weight: 700; }

/* ---------------------------------------------------------------- atmen */

.chips { display: flex; gap: 0.45rem; margin-top: 1rem; overflow-x: auto; padding-bottom: 0.2rem; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px;
  padding: 0.4rem 0.95rem;
  border-radius: var(--pill);          /* the app's chips are pills */
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
}
.chip.is-on { background: var(--terra); border-color: var(--terra); color: var(--on-terra); }

.pacer {
  position: relative;
  width: min(76vw, 310px);
  aspect-ratio: 1;
  margin: 1.6rem auto 0;
  display: grid; place-items: center;
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.pacer-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.pacer-ring .track { fill: none; stroke: var(--line); stroke-width: 1.5; }
.pacer-ring .dot { fill: var(--terra); }

/* The app's breathing orb: honey core into terracotta. */
.orb {
  width: 64%; aspect-ratio: 1; border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255,255,255,.95) 0%, rgba(255,255,255,0) 46%),
    radial-gradient(circle at 62% 70%, var(--honey) 0%, var(--terra) 62%, var(--terra-deep) 100%);
  box-shadow: 0 22px 55px -22px rgba(204, 115, 81, 0.85);
  transform: scale(0.42);
}

.pacer-read { position: absolute; display: grid; justify-items: center; gap: 0.1rem; pointer-events: none; }
.phase {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: #fff; text-shadow: 0 1px 10px rgba(120, 60, 30, 0.65);
}
.count {
  font-size: 2.5rem; font-weight: 300; color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 14px rgba(120, 60, 30, 0.6);
}
.idle {
  position: absolute;
  left: 50%; bottom: 13%;
  translate: -50% 0;
  white-space: nowrap;
  pointer-events: none;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-soft);
}

.tech-desc { margin-top: 1.4rem; font-size: 0.92rem; color: var(--ink-soft); text-align: center; }
.rounds { margin-top: 0.7rem; text-align: center; font-size: 0.85rem; color: var(--ink-soft); }
.rounds b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- stimmung */

.moods { display: flex; gap: 0.45rem; margin-top: 1.3rem; }
.mood {
  flex: 1; min-width: 0;
  aspect-ratio: 1 / 1.22;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  display: grid; place-items: center; gap: 0.25rem;
  padding: 0.4rem 0.2rem;
  font-size: 0.66rem; font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.25s var(--ease);
}
.mood svg { width: 26px; height: 26px; }
.mood.is-on { border-color: var(--m); background: var(--m); color: #fff; }
.mood-msg { margin-top: 1.1rem; font-size: 0.95rem; color: var(--ink-soft); min-height: 1.6em; }

.mood-history { display: grid; gap: 0.45rem; }
.mood-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.8rem 1rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.mood-row .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.mood-row time { margin-left: auto; font-size: 0.74rem; color: var(--ink-soft); }

/* ------------------------------------------------------------- tagebuch */

.prompt { margin-top: 0.9rem; font-size: 0.95rem; color: var(--terra-deep); font-weight: 600; }
.entry-input {
  width: 100%; min-height: 130px;
  margin-top: 0.85rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  font-size: 1rem;           /* 16px+ stops iOS zooming the field on focus */
  line-height: 1.6;
  resize: vertical;
}
.entry-input:focus { outline: none; border-color: var(--terra); }
.entry-input::placeholder { color: var(--ink-soft); opacity: .7; }

.entry-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.75rem; }
.count-chars { font-size: 0.8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.entries { margin-top: 1.5rem; display: grid; gap: 0.5rem; }
.entry {
  padding: 0.9rem 1rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.entry header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.35rem; }
.entry time { font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; }
.entry .del {
  background: none; border: 0; cursor: pointer;
  color: var(--ink-soft); font-size: 1.15rem; line-height: 1;
  padding: 0.2rem 0.45rem; min-height: 32px;
}
.entry.is-broken { border: 1px solid var(--mood-1); color: var(--mood-1); }
.empty { font-size: 0.89rem; color: var(--ink-soft); }

/* ----------------------------------------------------------------- mehr */

.card {
  margin-top: 0.9rem;
  padding: 1.25rem;
  background: var(--card);
  border-radius: var(--radius);   /* the app's GlassCard: flat, no shadow */
}
.card h3 { font-size: 1.02rem; font-weight: 700; margin-bottom: 0.6rem; }
.card-note { font-size: 0.87rem; color: var(--ink-soft); line-height: 1.6; }
.card-actions { display: flex; gap: 0.55rem; margin-top: 0.95rem; flex-wrap: wrap; }

.meter { height: 8px; border-radius: var(--pill); background: var(--raised); overflow: hidden; }
.meter i {
  display: block; height: 100%; width: 0%;
  border-radius: var(--pill);
  background: linear-gradient(90deg, var(--honey), var(--terra));
  transition: width 0.5s var(--ease), background 0.4s;
}
.meter.is-warn i { background: linear-gradient(90deg, #e8b45c, #d98a3c); }
.meter.is-full i { background: linear-gradient(90deg, var(--mood-1), #c96b74); }
.meter-label { margin-top: 0.55rem; font-size: 0.82rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.legal { margin-top: 1.5rem; font-size: 0.78rem; color: var(--ink-soft); text-align: center; }
.legal a { color: var(--ink-soft); }
.legal.dim { margin-top: 0.5rem; opacity: .8; line-height: 1.55; }

/* =================================================================== tabbar */

/* The app's NavigationBar: 68px, a pill indicator behind the active icon. */
.tabbar {
  flex: none;
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tabbar button {
  min-height: var(--tabbar-h);
  display: grid; place-items: center; gap: 0.2rem;
  background: none; border: 0; cursor: pointer;
  font-size: 0.68rem; font-weight: 600;
  color: var(--ink-soft);
  transition: color 0.25s;
}
.tabbar button .ti {
  font-size: 1.1rem; line-height: 1;
  padding: 0.18rem 0.85rem;
  border-radius: var(--pill);
  transition: background 0.25s var(--ease);
}
.tabbar button.is-on { color: var(--terra-deep); }
.tabbar button.is-on .ti { background: rgba(204, 115, 81, 0.16); }

/* ================================================================= consent */

.consent {
  position: fixed; inset: auto 0 0 0; z-index: 90;
  margin: 0.9rem;
  margin-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 0.9rem);
  padding: 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: consentIn 0.45s var(--ease);
}
@keyframes consentIn { from { opacity: 0; transform: translateY(14px); } }
.consent h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.5rem; }
.consent p { font-size: 0.87rem; color: var(--ink-soft); line-height: 1.6; }
.consent-never { margin-top: 0.55rem; color: var(--sage); font-weight: 600; }
/* Both choices carry identical weight — declining must not be the harder path. */
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; margin-top: 1rem; }
.consent-actions button {
  min-height: 48px;
  border-radius: var(--pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer;
}
.consent-link { display: block; margin-top: 0.8rem; text-align: center; font-size: 0.78rem; color: var(--ink-soft); }

/* ============================================== first-run limitation sheet */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 95;
  background: rgba(59, 46, 37, 0.45);
  display: grid; place-items: end center;
  padding: 1rem;
  animation: fadeIn 0.3s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: min(29rem, 100%);
  background: var(--card);
  border-radius: 28px;              /* the app's bottom-sheet radius */
  padding: 1.6rem 1.4rem calc(1.4rem + env(safe-area-inset-bottom));
  margin-bottom: 0.4rem;
  animation: sheetUp 0.45s var(--ease);
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } }
.sheet .grip {
  width: 38px; height: 4px; border-radius: var(--pill);
  background: var(--line); margin: 0 auto 1.1rem;
}
.sheet h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.7rem; }
.sheet p { font-size: 0.92rem; color: var(--ink-soft); line-height: 1.65; }
.sheet p + p { margin-top: 0.65rem; }
.sheet b { color: var(--terra-deep); font-weight: 600; }
.sheet .btn { width: 100%; margin-top: 1.3rem; }

/* =================================================================== toast */

.toast {
  position: fixed; z-index: 96;
  left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1rem);
  translate: -50% 0;
  max-width: min(88vw, 25rem);
  padding: 0.75rem 1.1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  text-align: center;
  animation: toastIn 0.32s var(--ease);
}
.toast.is-warn { background: var(--terra-deep); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ========================================================= reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* The pacer is the exception: its scaling *is* the instruction. */
  .orb { transition: transform 1s linear !important; }
}
