/* ==========================================================================
   MibCraft — styles.css

   Design tokens
   -------------
   Color:   charcoal background, Minecraft-grass green accent, warm off-white
            text. Deliberately desaturated/darkened accent so it reads
            "premium app" rather than "neon game UI".
   Type:    Press Start 2P (pixel) for the logo + big numbers only, used with
            restraint. Manrope for everything else. JetBrains Mono for
            quantities/counters — a nod to crafting-grid precision.
   Layout:  Single centered column, mobile-first, comfortable card rhythm.
   Signature: segmented "XP bar" style progress meters (blocky, beveled
            segments) instead of a smooth gradient bar — a modernized
            reference to Minecraft's own HUD bars.
   ========================================================================== */

/* -------------------------------------------------------------------- */
/* Tokens                                                                 */
/* -------------------------------------------------------------------- */
:root {
  --bg: #14171a;
  --bg-soft: #191d21;
  --surface: #1e2328;
  --surface-2: #262c32;
  --surface-glass: rgba(30, 35, 40, 0.66);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text-primary: #edf1ee;
  --text-secondary: #9aa5a0;
  --text-muted: #6b7570;

  --accent: #6cbb3c;
  --accent-bright: #93df57;
  --accent-dark: #427022;
  --accent-soft: rgba(108, 187, 60, 0.14);
  --accent-soft-strong: rgba(108, 187, 60, 0.24);
  --accent-contrast: #0e1409;

  --danger: #e2564b;
  --danger-soft: rgba(226, 86, 75, 0.14);
  --amber: #e0a83e;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-glow: 0 0 0 1px rgba(108, 187, 60, 0.25), 0 8px 28px rgba(108, 187, 60, 0.16);

  --font-display: 'Press Start 2P', monospace;
  --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --nav-h: 64px;
  --container-w: 640px;

  color-scheme: dark;
}

[data-theme='light'] {
  color-scheme: light;
  --bg: #f3f5f0;
  --bg-soft: #eaede5;
  --surface: #ffffff;
  --surface-2: #f1f4ee;
  --surface-glass: rgba(255, 255, 255, 0.7);
  --border: rgba(20, 30, 15, 0.1);
  --border-strong: rgba(20, 30, 15, 0.16);

  --text-primary: #1a201a;
  --text-secondary: #545f52;
  --text-muted: #838f80;

  --accent: #4c8a2a;
  --accent-bright: #5fa838;
  --accent-dark: #386420;
  --accent-soft: rgba(76, 138, 42, 0.1);
  --accent-soft-strong: rgba(76, 138, 42, 0.18);
  --accent-contrast: #f4fbef;

  --danger: #c8433a;
  --danger-soft: rgba(200, 67, 58, 0.1);

  --shadow-sm: 0 2px 8px rgba(20, 30, 15, 0.08);
  --shadow-md: 0 8px 24px rgba(20, 30, 15, 0.1);
  --shadow-glow: 0 0 0 1px rgba(76, 138, 42, 0.25), 0 8px 28px rgba(76, 138, 42, 0.14);
}

/* -------------------------------------------------------------------- */
/* Reset                                                                  */
/* -------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}
h1, h2, h3, h4, p, figure { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

::selection { background: var(--accent-soft-strong); color: var(--text-primary); }

/* Focus visibility for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------------- */
/* Background texture — faint crafting-grid, used behind hero/empty state */
/* -------------------------------------------------------------------- */
.craft-grid-bg {
  position: relative;
}
.craft-grid-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 34px 34px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 40%, transparent 85%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, #000 40%, transparent 85%);
  opacity: 0.55;
  pointer-events: none;
}

/* -------------------------------------------------------------------- */
/* Layout                                                                 */
/* -------------------------------------------------------------------- */
.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: 32px;
}
.page--fab-space {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.container {
  width: 100%;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--nav-h);
  padding: 0 16px;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__back {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}
.topbar__back:hover { background: var(--surface-2); transform: translateX(-2px); }
.topbar__title {
  font-weight: 700;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.topbar__action {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
}

/* -------------------------------------------------------------------- */
/* Logo / brand mark                                                      */
/* -------------------------------------------------------------------- */
.brand-mark {
  width: 112px;
  height: 112px;
  border-radius: 28px;
  margin: 0 auto;
  background: linear-gradient(155deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, var(--accent-soft), transparent 60%);
}
.brand-mark__glyph {
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--accent-bright);
  position: relative;
  text-shadow: 0 0 18px var(--accent-soft-strong);
}
.brand-mark__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none; /* shown by main.js only once the file actually loads */
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  text-align: center;
  margin-top: 22px;
  letter-spacing: 0.5px;
  line-height: 1.5;
}
.brand-title .accent { color: var(--accent-bright); }
.brand-tagline {
  text-align: center;
  color: var(--text-secondary);
  margin-top: 12px;
  font-size: 0.98rem;
  font-weight: 500;
}

/* -------------------------------------------------------------------- */
/* Buttons                                                                */
/* -------------------------------------------------------------------- */
.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 22px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.98rem;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: linear-gradient(155deg, var(--accent-bright), var(--accent));
  color: var(--accent-contrast);
  box-shadow: var(--shadow-glow);
}
.btn--primary:hover { filter: brightness(1.06); box-shadow: 0 0 0 1px var(--accent), 0 10px 30px rgba(108,187,60,0.24); }

.btn--secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--surface-2); border-color: var(--accent); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn--ghost:hover { color: var(--text-primary); border-color: var(--border-strong); }

.btn--danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(226, 86, 75, 0.3);
}
.btn--danger:hover { background: rgba(226, 86, 75, 0.22); }

.btn--full { width: 100%; }
.btn--sm { padding: 10px 16px; font-size: 0.86rem; border-radius: var(--radius-sm); }
.btn--icon { padding: 12px; width: 46px; height: 46px; border-radius: var(--radius-pill); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0);
  animation: ripple-anim 0.55s ease-out;
  pointer-events: none;
}
@keyframes ripple-anim {
  to { transform: scale(3.2); opacity: 0; }
}

/* Stack of main menu buttons on home */
.menu-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 36px;
}

/* -------------------------------------------------------------------- */
/* Cards                                                                  */
/* -------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  animation: fade-in-up 0.4s ease both;
}
.card--glass {
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------------- */
/* Segmented progress bar — signature element                            */
/* -------------------------------------------------------------------- */
.segbar {
  --seg-count: 20;
  display: grid;
  grid-template-columns: repeat(var(--seg-count), 1fr);
  gap: 3px;
  height: 20px;
  width: 100%;
}
.segbar__seg {
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: background 0.35s ease, border-color 0.35s ease;
}
.segbar__seg.is-filled {
  background: linear-gradient(180deg, var(--accent-bright), var(--accent));
  border-color: var(--accent-dark);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), inset 0 -2px 0 rgba(0,0,0,0.18);
}
.segbar__seg.is-filled.just-filled { animation: seg-pop 0.35s ease; }
@keyframes seg-pop {
  0% { transform: scaleY(0.4); }
  60% { transform: scaleY(1.15); }
  100% { transform: scaleY(1); }
}

.segbar--sm { height: 12px; --seg-count: 12; gap: 2px; }
.segbar--sm .segbar__seg { border-radius: 2px; }

.progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.progress-pct {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent-bright);
}
.progress-label {
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
}

/* -------------------------------------------------------------------- */
/* Material item card (on checklist page)                                */
/* -------------------------------------------------------------------- */
.material-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
  animation: fade-in-up 0.35s ease both;
}
.material-card.is-complete {
  background: var(--accent-soft);
  border-color: rgba(108, 187, 60, 0.35);
}
.material-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.material-card__name {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.material-card__name span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.material-card__need {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.check-badge {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.7rem;
  animation: pop-in 0.3s ease;
}
@keyframes pop-in {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.stepper__btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.stepper__btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }
.stepper__btn:active { transform: scale(0.92); }
.stepper__value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  width: 100%;
  text-align: center;
  background: transparent;
  border: none;
  -moz-appearance: textfield;
}
.stepper__value::-webkit-outer-spin-button,
.stepper__value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper__track { flex: 1; }

/* -------------------------------------------------------------------- */
/* Forms / inputs                                                        */
/* -------------------------------------------------------------------- */
.field {
  margin-bottom: 18px;
}
.field__label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  color: var(--text-primary);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-muted); }

.search-wrap { position: relative; }
.search-wrap .input { padding-left: 46px; }
.search-icon {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.autocomplete {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 340px;
  overflow-y: auto;
  z-index: 20;
  padding: 6px;
}
.autocomplete__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  animation: fade-in-up 0.2s ease both;
}
.autocomplete__item:hover { background: var(--accent-soft); }
.autocomplete__name { font-weight: 600; font-size: 0.95rem; }
.autocomplete__cat { font-size: 0.74rem; color: var(--text-muted); }
.autocomplete__add {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-bright);
  flex-shrink: 0;
}
.autocomplete__empty {
  padding: 22px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Selected item row on Create page */
.selected-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: fade-in-up 0.3s ease both;
}
.selected-item__name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-item__qty {
  width: 78px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
}
.selected-item__remove {
  width: 34px; height: 34px;
  border-radius: var(--radius-pill);
  display: grid; place-items: center;
  color: var(--danger);
  background: var(--danger-soft);
  flex-shrink: 0;
}

/* -------------------------------------------------------------------- */
/* Toggle switch (dark mode)                                             */
/* -------------------------------------------------------------------- */
.toggle {
  width: 50px; height: 30px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background 0.25s ease;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform 0.25s ease, background 0.25s ease;
}
.toggle[aria-pressed='true'] { background: var(--accent-soft-strong); border-color: var(--accent); }
.toggle[aria-pressed='true']::after { transform: translateX(20px); background: var(--accent-bright); }

.row-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px;
}

/* -------------------------------------------------------------------- */
/* Checklist list cards ("My Checklists")                                 */
/* -------------------------------------------------------------------- */
.list-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}
.list-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.list-card__name { font-weight: 800; font-size: 1.08rem; }
.list-card__date { color: var(--text-muted); font-size: 0.8rem; margin-top: 3px; }
.list-card__pct {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-bright);
  font-size: 1.1rem;
  flex-shrink: 0;
}
.list-card__actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.list-card__actions .btn { flex: 1; }

/* -------------------------------------------------------------------- */
/* Sticky bottom action bar                                              */
/* -------------------------------------------------------------------- */
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.bottom-bar > .container { display: flex; gap: 10px; padding: 0; }

/* -------------------------------------------------------------------- */
/* Empty states                                                          */
/* -------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  border-radius: var(--radius-lg);
}
.empty-state__title { font-weight: 800; font-size: 1.1rem; margin-bottom: 8px; }
.empty-state__desc { color: var(--text-secondary); font-size: 0.92rem; max-width: 30ch; margin: 0 auto; }
.empty-state .btn { margin-top: 20px; }

/* -------------------------------------------------------------------- */
/* Section headings / misc                                                */
/* -------------------------------------------------------------------- */
.section-title {
  font-weight: 800;
  font-size: 1.3rem;
  margin-bottom: 18px;
}
.eyebrow {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin-bottom: 6px;
  display: block;
}
.muted { color: var(--text-secondary); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  white-space: nowrap;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* -------------------------------------------------------------------- */
/* Responsive                                                             */
/* -------------------------------------------------------------------- */
@media (min-width: 560px) {
  .list-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
@media (min-width: 768px) {
  :root { --container-w: 720px; }
  .page, .page--fab-space { padding-bottom: 40px; }
  .bottom-bar { position: static; background: transparent; backdrop-filter: none; border-top: none; padding: 24px 0 0; }
  .bottom-bar > .container { padding: 0; }
  .brand-mark { width: 132px; height: 132px; }
}
