/* ============================================================
   styles.css  —  THE DESIGN
   ------------------------------------------------------------
   CSS decides how the page LOOKS: colors, sizes, spacing.
   Each block below has this shape:

       what-to-style {
         property: value;
       }

   A name starting with a dot (.card) styles every element that
   has class="card" in the HTML. A name starting with # styles
   the one element with that id.

   THE LOOK WE ARE GOING FOR: "playful but professional".
     - Friendly rounded headings, soft pastel colors, a mascot.
     - Chunky buttons that "press down" when clicked.
     - But: lots of white space, tidy tables, easy-to-read numbers.

   PRIVACY NOTE: we use only fonts already on the user's device.
   Loading fonts from another company's server (e.g. Google
   Fonts) would tell that company about every visitor.
   ============================================================ */

/* ---------- 1. Colors and sizes used everywhere ----------
   These are "variables". Change a color here and it changes
   across the whole site. */
:root {
  --bg: #fff8ec;          /* page background (warm cream) */
  --dot: #f3e6cf;         /* the tiny dots in the background */
  --surface: #ffffff;     /* cards and tables */
  --ink: #22303c;         /* main text and outlines (dark navy) */
  --muted: #5b6876;       /* less important text */
  --line: #e6dcc8;        /* thin dividing lines */
  --brand: #0f7a63;       /* main teal-green */
  --brand-text: #ffffff;  /* text on top of the green */
  --ok: #0f7a63;
  --low: #a05a00;
  --out: #c0352b;
  /* Pastel "crayon" colors for the number boxes */
  --sun: #ffe08a;
  --mint: #c4f1d6;
  --sky: #bfe6ff;
  --grape: #ddd3ff;
  --coral: #ffd0c4;
  --radius: 16px;
  --round-font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Varela Round",
                -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* If the user's device is set to dark mode, swap the colors. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161b22;
    --dot: #202733;
    --surface: #212936;
    --ink: #f1f4f8;
    --muted: #a9b4c2;
    --line: #36414f;
    --brand: #56c9a9;
    --brand-text: #0c231d;
    --ok: #56c9a9;
    --low: #f0b45c;
    --out: #ff9a8f;
    --sun: #4d4320;
    --mint: #1f4636;
    --sky: #1f3f57;
    --grape: #39325c;
    --coral: #57312a;
  }
}

/* ---------- 2. Basics ---------- */
* { box-sizing: border-box; }             /* makes widths behave predictably */
[hidden] { display: none !important; }    /* "hidden" in the HTML always wins */

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--bg);
  /* A soft pattern of dots, drawn by CSS (no image file needed). */
  background-image: radial-gradient(var(--dot) 1.6px, transparent 1.6px);
  background-size: 22px 22px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, .brand-name, .btn, .nav button, .stat-value, summary { font-family: var(--round-font); }
h1 { font-size: 1.9rem; margin: 0 0 0.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }
.card h2:first-child { margin-top: 0; }
a { color: var(--brand); font-weight: 600; }
p { margin: 0 0 0.75rem; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 60ch; }
.hint { color: var(--muted); font-size: 0.92rem; max-width: 75ch; }
.optional { color: var(--muted); font-weight: normal; font-size: 0.85rem; }

/* ---------- 3. Top bar and menu ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--ink);
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;                 /* on small screens the menu drops below the name */
  gap: 0.6rem 1.5rem;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.brand-logo { width: 40px; height: 40px; flex: none; }
.brand:hover .brand-logo { animation: wiggle 0.5s ease; }      /* the mascot wiggles when you point at it */
.brand-name { font-weight: 800; font-size: 1.3rem; color: var(--brand); }
.brand-business { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.nav button {
  border: 2px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;            /* fully rounded "pill" shape */
  cursor: pointer;
}
.nav button:hover { background: var(--mint); }
.nav button.active { background: var(--sun); border-color: var(--ink); }   /* the page you are on */

/* ---------- 4. Page layout ---------- */
.main { max-width: 1050px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.view-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; }

/* A "card" is a white box with a dark outline and a soft offset shadow. */
.card {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 5px 5px 0 var(--line);
  padding: 1.15rem;
  margin: 1rem 0;
}

/* The welcome banner with the mascot. */
.hero { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.hero img { width: 110px; height: 110px; animation: bob 3s ease-in-out infinite; }

/* The colorful number boxes on the Dashboard. */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));  /* as many per row as fit */
  gap: 0.85rem;
  margin: 1rem 0;
}
.stat {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  transition: transform 0.15s ease;
}
.stat:hover { transform: translateY(-3px) rotate(-0.6deg); }     /* a tiny playful lift */
.stat-label { font-size: 0.86rem; font-weight: 600; display: flex; align-items: center; gap: 0.35rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.tone-1 { background: var(--sun); }
.tone-2 { background: var(--mint); }
.tone-3 { background: var(--sky); }
.tone-4 { background: var(--grape); }
.tone-5 { background: var(--coral); }
.stat.highlight { box-shadow: 4px 4px 0 var(--ink); }            /* the most important number stands out */

/* Quick-action buttons on the Dashboard. */
.quick { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0; }

/* The "Getting started" checklist. */
.checklist { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.checklist li { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.check-dot {
  width: 1.6rem; height: 1.6rem; flex: none;
  border: 2px solid var(--ink); border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 0.9rem;
  background: var(--surface);
}
.checklist li.done .check-dot { background: var(--mint); }
.checklist li.done .check-text { color: var(--muted); text-decoration: line-through; }
.progress { height: 12px; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: var(--surface); max-width: 320px; }
.progress-bar { height: 100%; background: var(--brand); transition: width 0.4s ease; }

/* ---------- 5. Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem 1rem;
}
.field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0 0 0.75rem; border: 0; padding: 0; min-width: 0; }
.form-grid .field { margin: 0; }
.field.wide { grid-column: 1 / -1; }      /* stretch across the whole row */
.field.narrow { max-width: 220px; }
.field.inline { flex-direction: row; align-items: center; gap: 0.5rem; margin: 0; }
label, legend { font-weight: 700; font-size: 0.92rem; padding: 0; }
.field > label { display: flex; align-items: center; flex-wrap: wrap; }   /* keeps the "?" on the same line as the label */
.field.inline > label { flex-wrap: nowrap; white-space: nowrap; }

input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="month"],
input[type="email"], input[type="password"], select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 0.5rem 0.7rem;
  width: 100%;
  min-height: 2.75rem;                     /* big enough to tap on a phone */
}
input::placeholder { color: var(--muted); }
input:focus-visible, select:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible {
  outline: 3px solid var(--brand);         /* clear outline for keyboard users */
  outline-offset: 2px;
}

.check { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: normal; margin: 1rem 0; }
.check input { margin-top: 0.3rem; width: 1.15rem; height: 1.15rem; flex: none; accent-color: var(--brand); }

/* The store-type choices on the Welcome page. */
.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0.85rem; }
.type-option {
  display: block;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.85rem;
  cursor: pointer;
  font-weight: normal;
  background: var(--surface);
  transition: transform 0.15s ease;
}
.type-option:hover { transform: translateY(-3px); }
.type-option:nth-child(1):has(input:checked) { background: var(--sun); }
.type-option:nth-child(2):has(input:checked) { background: var(--sky); }
.type-option:nth-child(3):has(input:checked) { background: var(--grape); }
.type-option:has(input:checked) { box-shadow: 4px 4px 0 var(--ink); }
.type-option input { accent-color: var(--brand); }
.type-option strong { display: block; font-size: 1.05rem; font-family: var(--round-font); }
.type-option .method { font-weight: 700; font-size: 0.88rem; }
.type-option small { color: var(--muted); display: block; margin-top: 0.25rem; }
.type-option:has(input:checked) small { color: var(--ink); }

/* One ingredient row in a recipe. */
.recipe-row { display: grid; grid-template-columns: 1fr 110px auto; gap: 0.5rem; margin-bottom: 0.5rem; align-items: center; }

/* The fold-out "Add many at once" box. */
details.card > summary { cursor: pointer; font-weight: 800; font-size: 1.05rem; }
details.card[open] > summary { margin-bottom: 0.75rem; }
.steps { margin: 0 0 0.5rem; padding-left: 1.25rem; }
.steps li { margin-bottom: 0.3rem; }
.report { margin-top: 0.85rem; padding: 0.75rem 1rem; border: 2px dashed var(--ink); border-radius: 12px; background: var(--bg); }
.report ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }

/* The log-in card. */
.auth-card { max-width: 460px; }
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.tab {
  flex: 1; font-family: var(--round-font); font-size: 1rem; font-weight: 800;
  padding: 0.5rem; border: 2px solid var(--ink); border-radius: 12px;
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.tab.active { background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
.auth-links { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; margin: 1.1rem 0 0; }
/* A button that looks like a link (for small secondary actions). */
.link {
  border: 0; background: none; padding: 0.2rem 0; font: inherit; font-weight: 600;
  color: var(--brand); text-decoration: underline; cursor: pointer; text-align: left;
}

/* The small "Saved to your account" label in the top bar. */
.sync { font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.55rem; border-radius: 999px; border: 2px solid var(--line); color: var(--muted); white-space: nowrap; }
.sync.ok { border-color: var(--ok); color: var(--ok); }
.sync.offline { border-color: var(--low); color: var(--low); }

/* A plain fold-out ("More numbers", "More options"). */
details.more { margin: 0.75rem 0; }
details.more > summary { cursor: pointer; font-weight: 800; color: var(--brand); width: fit-content; padding: 0.2rem 0; }
details.more[open] > summary { margin-bottom: 0.5rem; }

#imp-preview, #imp-names { margin: 0.75rem 0 1rem; }      /* breathing room around the wizard tables */

/* A slim strip with a message and one button (used on the Record page). */
.banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem;
  background: var(--sky); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 0.7rem 1rem; margin: 1rem 0;
}

/* The 1-2-3-4 progress row of the import wizard. */
.stepper { list-style: none; counter-reset: step; display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 1rem 0; }
.stepper li {
  counter-increment: step;
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--round-font); font-weight: 700; font-size: 0.9rem; color: var(--muted);
  border: 2px solid var(--line); border-radius: 999px; padding: 0.2rem 0.8rem 0.2rem 0.3rem; background: var(--surface);
}
.stepper li::before {
  content: counter(step);
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--line); color: var(--ink); font-size: 0.8rem;
}
.stepper li.current { color: var(--ink); border-color: var(--ink); background: var(--sun); }
.stepper li.current::before { background: var(--ink); color: var(--bg); }
.stepper li.done { color: var(--ink); border-color: var(--ink); }
.stepper li.done::before { content: "✓"; background: var(--mint); }

/* The Undo button in the top bar. */
.nav .undo { background: var(--coral); border-color: var(--ink); }
.nav .undo:hover { background: var(--sun); }

/* ---------- 6. Buttons ----------
   Buttons have a solid shadow underneath. When pressed, the
   button moves down and the shadow disappears, like a real key. */
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.row-actions { display: inline-flex; gap: 0.4rem; }   /* Edit/Delete buttons inside a table row */
.btn {
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 1rem;
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  display: inline-block;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:hover { background: var(--mint); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--brand); color: var(--brand-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sunny { background: var(--sun); }
.btn.danger { color: var(--out); }
.btn.danger:hover { background: var(--coral); }
.btn.small { padding: 0.2rem 0.6rem; font-size: 0.86rem; box-shadow: 0 2px 0 var(--ink); border-radius: 10px; }
.btn.small:active { transform: translateY(2px); }

/* ---------- 7. Tables ---------- */
.table-wrap { overflow-x: auto; border: 2px solid var(--ink); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.94rem; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 0.82rem; font-weight: 700; background: var(--sun); border-bottom: 2px solid var(--ink); }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }  /* numbers line up on the right */
td.wrap { white-space: normal; min-width: 12rem; }

/* A friendly box shown when a list is still empty. */
.empty {
  display: flex; align-items: center; gap: 0.9rem;
  color: var(--muted); padding: 0.9rem 1rem;
  border: 2px dashed var(--muted); border-radius: var(--radius); background: var(--surface);
}
.empty img { width: 56px; height: 56px; flex: none; }
.empty p { margin: 0; }

/* Status labels: OK / Reorder / Out of stock (text + color, never color alone). */
.badge { font-size: 0.8rem; font-weight: 800; padding: 0.15rem 0.55rem; border-radius: 999px; border: 2px solid currentColor; }
.badge.ok { color: var(--ok); }
.badge.low { color: var(--low); }
.badge.out { color: var(--out); }

/* ---------- 8. Help tips ----------
   The small "?" circle next to a label, and the bubble that
   appears when you point at it (or tap it on a phone). */
.tip {
  width: 1.25rem; height: 1.25rem; padding: 0; margin-left: 0.35rem;
  border: 2px solid var(--ink); border-radius: 50%;
  background: var(--sky); color: var(--ink);
  font-size: 0.72rem; font-weight: 800; line-height: 1;
  cursor: help; vertical-align: middle; flex: none;
}
.tip:hover { background: var(--sun); }
.tip-bubble {
  position: fixed; z-index: 50; max-width: min(280px, calc(100vw - 16px));
  background: var(--ink); color: var(--bg);
  padding: 0.55rem 0.75rem; border-radius: 12px;
  font-size: 0.88rem; line-height: 1.4;
  pointer-events: none;                    /* the bubble never blocks clicks */
  animation: pop 0.12s ease-out;
}

/* ---------- 9. Message box, footer, helpers ---------- */
.toast {
  position: sticky; top: 0.5rem; z-index: 10;
  max-width: 1050px; margin: 0.6rem auto 0;
  background: var(--mint); border: 2px solid var(--ink); border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 0.6rem 1rem; width: calc(100% - 2rem); font-weight: 600;
  animation: pop 0.2s ease-out;
}
.toast.error { background: var(--coral); }

.footer {
  border-top: 2px solid var(--ink);
  background: var(--surface);
  padding: 1rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: center;
  color: var(--muted); font-size: 0.88rem;
}

/* Hides the plain file-picker. A normal button opens it instead. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Used on the Privacy page for readable long text. */
.prose { max-width: 70ch; }
.prose li { margin-bottom: 0.35rem; }
.notice { background: var(--mint); border: 2px solid var(--ink); padding: 0.75rem 1rem; border-radius: 12px; }
.notice.warn { background: var(--sun); }

/* TOUCH SCREENS (phones and tablets): fingers are less precise than a mouse,
   so the small "?" circles and the small table buttons get bigger. */
@media (pointer: coarse) {
  .tip { width: 1.9rem; height: 1.9rem; font-size: 0.95rem; }
  .btn.small { padding: 0.5rem 0.8rem; font-size: 0.95rem; min-height: 2.5rem; }
}

/* ---------- 10. Small animations ---------- */
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ACCESSIBILITY: some people get dizzy from movement. If their device
   is set to "reduce motion", we switch every animation off. */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .stat:hover, .type-option:hover { transform: none; }
}
