/* The Oikonomia household app: one column, one obvious action per screen. */

@import "/styles/base.css";

body {
  padding-bottom: env(safe-area-inset-bottom);
}

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

/* ---------------------------------------------------------------- */
/* top bar                                                           */
/* ---------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: var(--page);
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title .eyebrow {
  font-size: 0.7rem;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.1rem;
}

/* Saving state is always visible, never a silent guess. */
.save-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}

.save-chip.saved { color: var(--green); background: var(--green-wash); border-color: transparent; }
.save-chip.saving { color: var(--ink-soft); }
.save-chip.waiting { color: var(--amber); background: var(--amber-wash); border-color: transparent; }
.save-chip.conflict { color: var(--red); background: var(--red-wash); border-color: transparent; }

/* ---------------------------------------------------------------- */
/* page                                                              */
/* ---------------------------------------------------------------- */

.page {
  flex: 1;
  width: var(--page);
  margin: 0 auto;
  padding: 20px 16px calc(96px + env(safe-area-inset-bottom));
  display: grid;
  gap: var(--gap);
  align-content: start;
}

.page-intro h2 {
  font-size: 1.45rem;
}

.page-intro p {
  color: var(--ink-soft);
  margin-top: 6px;
}

/* ---------------------------------------------------------------- */
/* bottom navigation: four destinations, words under every icon      */
/* ---------------------------------------------------------------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar button {
  min-height: 60px;
  display: grid;
  gap: 2px;
  justify-items: center;
  align-content: center;
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--ink-faint);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 8px 4px;
}

.tabbar button .tab-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.tabbar button[aria-current="page"] {
  color: var(--green);
}

/* ---------------------------------------------------------------- */
/* the concern card: what matters now                                */
/* ---------------------------------------------------------------- */

.headline-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lift);
  display: grid;
  gap: 12px;
}

.headline-card.tone-urgent { border-left-color: var(--red); }
.headline-card.tone-attention { border-left-color: var(--amber); }
.headline-card.tone-good { border-left-color: var(--green); }
.headline-card.tone-calm { border-left-color: var(--line-strong); }

.headline-card h2 {
  font-size: 1.3rem;
}

.headline-card .why {
  color: var(--ink-soft);
}

.concern {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.concern .concern-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.concern .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-top: 8px;
  flex: none;
  background: var(--line-strong);
}

.concern.tone-urgent .dot { background: var(--red); }
.concern.tone-attention .dot { background: var(--amber); }
.concern.tone-good .dot { background: var(--green); }

/* ---------------------------------------------------------------- */
/* figures: a number never appears without its evidence              */
/* ---------------------------------------------------------------- */

.figure {
  display: grid;
  gap: 4px;
}

.figure .figure-label {
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.figure .figure-value {
  font-size: 1.9rem;
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.figure.figure-lg .figure-value { font-size: 2.4rem; }
.figure.figure-sm .figure-value { font-size: 1.25rem; }

.figure .figure-unknown {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink-faint);
}

.figure .figure-period {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.figure-meaning {
  font-size: 0.85rem;
  color: var(--ink-soft);
  border-left: 2px solid var(--line);
  padding-left: 10px;
  margin-top: 4px;
}

.evidence-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-sunk);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.evidence-chip.confirmed { background: var(--green-wash); color: var(--green); border-color: transparent; }
.evidence-chip.reconciled { background: var(--blue-wash); color: var(--ink-soft); border-color: transparent; }
.evidence-chip.likely { background: var(--amber-wash); color: var(--amber); border-color: transparent; }
.evidence-chip.needs-check { background: var(--amber-wash); color: var(--amber); border-color: transparent; }
.evidence-chip.unknown { background: var(--surface-sunk); color: var(--ink-faint); }

.evidence-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ---------------------------------------------------------------- */
/* lists                                                             */
/* ---------------------------------------------------------------- */

.list {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.list-row {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  padding: 14px 16px;
  min-height: var(--tap);
  text-align: left;
  width: 100%;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.list-row:hover { background: var(--surface-sunk); }

.list-row .row-main { flex: 1; min-width: 0; }
.list-row .row-main strong { display: block; }
.list-row .row-main span { display: block; font-size: 0.83rem; color: var(--ink-soft); }
.list-row .row-value { text-align: right; font-weight: 640; white-space: nowrap; }
.list-row .row-value small { display: block; font-weight: 500; font-size: 0.75rem; color: var(--ink-soft); }

.row-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface-sunk);
  font-size: 1.05rem;
}

/* ---------------------------------------------------------------- */
/* bars                                                              */
/* ---------------------------------------------------------------- */

.bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-sunk);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 999px;
}

.bar.over span { background: var(--red); }
.bar.warn span { background: var(--amber); }

/* ---------------------------------------------------------------- */
/* stages: real progress only                                        */
/* ---------------------------------------------------------------- */

.stages {
  display: grid;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.stages li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  font-size: 0.92rem;
  color: var(--ink-faint);
}

.stages li .stage-mark {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line-strong);
  font-size: 0.72rem;
  font-weight: 700;
}

.stages li.done { color: var(--ink); }
.stages li.done .stage-mark { background: var(--green); border-color: var(--green); color: #fff; }
.stages li.active { color: var(--ink); font-weight: 600; }
.stages li.active .stage-mark { border-color: var(--green); color: var(--green); }
.stages li.failed .stage-mark { border-color: var(--red); color: var(--red); }
.stages li.failed { color: var(--red); }

/* ---------------------------------------------------------------- */
/* sheets: forms arrive from the bottom, within thumb reach          */
/* ---------------------------------------------------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 26, 22, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  background: var(--surface);
  width: min(560px, 100%);
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lift);
}

@media (min-width: 640px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 24px; }
}

.sheet-grip {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  margin: 8px auto 14px;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.sheet-head h2 { flex: 1; }

/* ---------------------------------------------------------------- */
/* forms                                                             */
/* ---------------------------------------------------------------- */

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field > label {
  font-weight: 600;
  font-size: 0.95rem;
}

.field .hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  font-size: 1.05rem;
}

.field textarea { min-height: 96px; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  outline: none;
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-height: var(--tap);
  font: inherit;
  color: inherit;
}

.choice[aria-pressed="true"],
.choice.selected {
  border-color: var(--green);
  background: var(--green-wash);
}

.choice strong { display: block; }
.choice span { display: block; font-size: 0.85rem; color: var(--ink-soft); }

/* ---------------------------------------------------------------- */
/* question card: one at a time                                      */
/* ---------------------------------------------------------------- */

.question-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}

.question-card h2 { font-size: 1.3rem; }
.question-card .why { color: var(--ink-soft); font-size: 0.92rem; }
.question-card .question-count { font-size: 0.78rem; color: var(--ink-faint); font-weight: 600; }

/* ---------------------------------------------------------------- */
/* notices                                                           */
/* ---------------------------------------------------------------- */

.notice {
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.notice.warn { background: var(--amber-wash); border-color: transparent; }
.notice.bad { background: var(--red-wash); border-color: transparent; }
.notice.good { background: var(--green-wash); border-color: transparent; }
.notice.info { background: var(--blue-wash); border-color: transparent; }

.empty {
  display: grid;
  gap: 12px;
  padding: 26px 20px;
  text-align: center;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.empty .empty-icon { font-size: 1.8rem; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 80;
  background: var(--green-deep);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: var(--shadow-lift);
  max-width: calc(100% - 32px);
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .toast { background: var(--green-wash); color: var(--ink); }
}

/* ---------------------------------------------------------------- */
/* more menu                                                         */
/* ---------------------------------------------------------------- */

.menu-group {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.menu-item {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 0;
  padding: 15px 16px;
  min-height: var(--tap);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  text-decoration: none;
}

.menu-item:hover { background: var(--surface-sunk); }
.menu-item .menu-icon { font-size: 1.15rem; width: 28px; text-align: center; }
.menu-item .menu-text { flex: 1; }
.menu-item .menu-text span { display: block; font-size: 0.82rem; color: var(--ink-soft); }
.menu-item .menu-arrow { color: var(--ink-faint); }

/* ---------------------------------------------------------------- */
/* wide content                                                      */
/* ---------------------------------------------------------------- */

/* Anything wider than the phone scrolls inside its own box; the page never does. */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.scroll-x > * {
  min-width: max-content;
}

/* ---------------------------------------------------------------- */
/* segmented control                                                 */
/* ---------------------------------------------------------------- */

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-sunk);
  border-radius: 999px;
}

.segmented button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 999px;
  background: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- */
/* desktop: the same one column, with room around it                 */
/* ---------------------------------------------------------------- */

@media (min-width: 900px) {
  :root { --page: 760px; }

  .tabbar {
    top: 0;
    bottom: auto;
    left: 0;
    right: auto;
    width: 124px;
    height: 100dvh;
    grid-template-columns: 1fr !important;
    align-content: start;
    padding: 76px 8px 0;
    gap: 4px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--surface);
  }

  .tabbar button {
    border-radius: 12px;
    min-height: 68px;
  }

  .tabbar button[aria-current="page"] { background: var(--green-wash); }

  .app { padding-left: 124px; }
  .topbar-inner { padding-left: 16px; }
  .page { padding-bottom: 60px; }
  .toast { bottom: 32px; }
}
