/* ==========================================================================
   STRUCTURE — the design system. Do not edit per project; use theme.css.
   Mobile-first: base styles are the phone layout.
   ========================================================================== */

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

[hidden] { display: none !important; }

html, body { height: 100%; }

/* All gradients are derived from the flat theme colors with color-mix(),
   so theme.css stays a simple list of ~12 solid colors. */
body {
  background:
    radial-gradient(120% 90% at 50% -10%,
      color-mix(in srgb, var(--bg), white 10%) 0%, transparent 60%),
    radial-gradient(150% 100% at 50% 118%,
      color-mix(in srgb, var(--bg), black 16%) 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px)
           calc(env(safe-area-inset-right) + 16px)
           calc(env(safe-area-inset-bottom) + 16px)
           calc(env(safe-area-inset-left) + 16px);
  max-width: 680px;
  margin: 0 auto;
}

/* ---- Top bar ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.topbar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg-inset), white 8%),
    color-mix(in srgb, var(--bg-inset), black 10%));
  box-shadow: inset 0 1px 0 color-mix(in srgb, white, transparent 88%);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { opacity: 0.7; }

/* ---- Progress ------------------------------------------------------------ */

.progress {
  display: flex;
  gap: 6px;
  padding: 14px 2px;
}

.progress .seg {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--progress-track);
  transition: flex 0.35s ease, background-color 0.35s ease;
}

.progress .seg.active {
  flex: 3;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--accent), white 18%),
    var(--accent));
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent), transparent 65%);
}

.progress .seg.done { background: var(--accent); opacity: 0.45; }

/* Feed mode: one continuous bar */
.progress .bar {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--progress-track);
  overflow: hidden;
}

.progress .bar .fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--accent), white 18%),
    var(--accent));
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent), transparent 65%);
}

/* ---- Card container ------------------------------------------------------ */

.cards { flex: 1; min-height: 0; display: flex; }

.state-msg {
  margin: auto;
  color: var(--text-muted);
  font-size: 15px;
  text-align: center;
  line-height: 1.5;
  padding: 24px;
}

/* Deck mode: horizontal snap scroller.
   Cards hug their content: align-items lets each card end where its
   content ends instead of stretching to the bottom of the screen. */
.cards.deck {
  flex-direction: row;
  align-items: flex-start;
  gap: 24px;
  padding: 8px 8px 28px; /* room for the card's outer frame + shadow */
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.cards.deck::-webkit-scrollbar { display: none; }

.cards.deck .card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

/* Feed mode: vertical stack */
.cards.feed {
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 8px 8px 32px; /* room for the card's outer frame + shadow */
}
.cards.feed::-webkit-scrollbar { display: none; }

.cards.feed .card { flex: 0 0 auto; }

/* ---- Card ----------------------------------------------------------------- */

.card {
  background:
    linear-gradient(172deg,
      color-mix(in srgb, var(--bg-card), white 9%) 0%,
      var(--bg-card) 42%,
      color-mix(in srgb, var(--bg-card), var(--bg) 60%) 100%);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, white, transparent 86%),   /* top sheen        */
    0 0 0 6px color-mix(in srgb, var(--bg-card), var(--bg) 62%), /* outer frame ring */
    0 20px 45px -14px color-mix(in srgb, black, transparent 70%); /* drop shadow    */
  padding: 26px 24px 20px;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}
.card::-webkit-scrollbar { display: none; }

.card-text {
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.65;
}

.card-text p + p { margin-top: 1em; }

.card-img {
  width: 100%;
  border-radius: calc(var(--radius) - 8px);
  margin-top: 20px;
}

.card-footer {
  margin-top: auto;
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-footer .icon-btn { background: transparent; color: var(--text-muted); }
.card-footer .icon-btn.saved { color: var(--accent); }
.card-footer .icon-btn.saved svg { fill: currentColor; }

/* ---- Input cards ----------------------------------------------------------- */

.prompt {
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1.45;
  margin-bottom: 20px;
}

.field {
  width: 100%;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--bg-inset);
  box-shadow: inset 0 2px 8px color-mix(in srgb, black, transparent 85%);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.5;
  padding: 14px 16px;
  caret-color: var(--accent);
  outline: none;
  resize: none;
}

.field::placeholder { color: var(--text-muted); }
.field:focus { border-color: var(--accent); }

textarea.field { min-height: 120px; }

.pills { display: flex; flex-wrap: wrap; gap: 10px; }

.pill {
  border: 2px solid var(--card-border);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pill.selected {
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent), white 12%),
    color-mix(in srgb, var(--accent), black 8%));
  border-color: color-mix(in srgb, var(--accent), white 15%);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent), transparent 70%);
  color: var(--accent-contrast);
  font-weight: 600;
}

.submit-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
}

.btn-submit {
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--accent), white 14%),
    color-mix(in srgb, var(--accent), black 10%));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, white, transparent 70%),
    0 6px 18px color-mix(in srgb, var(--accent), transparent 68%);
  color: var(--accent-contrast);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  padding: 12px 28px;
  cursor: pointer;
}

.btn-submit:disabled { opacity: 0.5; cursor: default; }
.btn-submit:active:not(:disabled) { transform: scale(0.97); }

.form-note { font-size: 14px; color: var(--text-muted); }
.form-note.ok { color: var(--accent); }
.form-note.err { color: var(--error, #ff8f7a); }

/* ---- Desktop --------------------------------------------------------------- */

@media (min-width: 720px) {
  #app { padding-top: 32px; padding-bottom: 32px; }
  .card { padding: 36px 34px 26px; }
  .card-text { font-size: 20px; }
}
