/* ============================================================
   Sqeak — a squeaky little recipe-to-diagram app
   Playful sticker style: warm cream, chunky ink borders,
   hard offset shadows, and a sunny amber / coral / teal palette.
   ============================================================ */

:root {
  --bg: #fff3dc;
  --surface: #fffdf7;
  --ink: #3a2a33;
  --muted: #8c7b6d;
  --line: #eed9b9;
  --accent: #ffb627;
  --accent-deep: #f59f00;
  --accent-ink: #3a2a33;
  --accent-soft: #ffe9b8;
  --coral: #ff6b5e;
  --teal: #0f8b7d;
  --teal-deep: #0b6b60;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow-sm: 0 1px 2px rgba(58,42,51,.08);
  --shadow: 0 3px 0 rgba(58,42,51,.16);
  --shadow-hard: 4px 4px 0 var(--ink);
  --shadow-hard-sm: 3px 3px 0 var(--ink);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(58,42,51,.09) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
}

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

.app { max-width: 640px; margin: 0 auto; padding: 0 20px 64px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 0 14px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.brand:active { transform: translateY(1px); }
.brand-logo {
  width: 36px; height: 36px; border-radius: 13px;
  background: var(--accent);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-hard-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; line-height: 1;
}
.brand-name { font-weight: 900; font-size: 21px; letter-spacing: -0.02em; }
.topbar-tag {
  font-size: 12.5px; font-weight: 700; color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 11px;
  box-shadow: 2px 2px 0 var(--ink);
  white-space: nowrap;
}

/* ---------- Screens ---------- */
.screen { padding-top: 8px; }
.screen[hidden] { display: none; }
.screen-center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; gap: 16px; text-align: center; }

/* ---------- Hero ---------- */
.hero { position: relative; margin: 28px 0 30px; }
.hero h1 { font-size: 36px; line-height: 1.08; letter-spacing: -0.025em; margin: 0 0 14px; font-weight: 900; padding-right: 78px; }
.hero .sub { font-size: 16px; color: var(--muted); margin: 0; max-width: 46ch; font-weight: 500; }

.burst {
  position: absolute; top: -14px; right: 2px;
  transform: rotate(6deg);
  display: inline-flex; align-items: center;
  background: var(--coral); color: #fff;
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow-hard-sm);
  font-size: 12.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em;
  padding: 5px 11px;
  animation: wobble 3.4s ease-in-out infinite;
  transform-origin: 70% 100%;
}
@keyframes wobble {
  0%, 100% { transform: rotate(6deg); }
  50% { transform: rotate(-2deg); }
}

/* ---------- Paste card ---------- */
.paste {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-hard);
}
.field-label { display: block; font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .07em; }
.url-field { position: relative; }
.url-input {
  width: 100%; font-size: 16px; padding: 14px 16px;
  padding-right: 58px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  outline: none;
  -webkit-appearance: none; appearance: none;
  box-shadow: inset 0 0 0 0 transparent;
}
.url-input::placeholder { color: #b9a98f; }
.url-input:focus { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }

/* Clear button: a big, thumb-friendly ✕ parked inside the field.
   Hidden by default; app.js reveals it only when there is text. */
.clear-btn {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  min-width: 44px; min-height: 44px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-size: 17px; font-weight: 900; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
}
.clear-btn:hover { background: var(--accent-soft); }
.clear-btn:active { transform: translateY(-50%) translate(2px, 2px); box-shadow: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px solid var(--ink);
  cursor: pointer; font-family: inherit; font-weight: 800; font-size: 16px;
  border-radius: 999px; padding: 13px 22px; min-height: 50px;
  text-decoration: none;
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
}
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn-primary {
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 3px 3px 0 var(--ink);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-deep); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: var(--surface); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-submit { width: 100%; margin-top: 14px; }
.btn-back { min-height: 40px; padding: 8px 16px; font-size: 14px; }
.hint { font-size: 13px; color: var(--muted); margin: 14px 0 0; font-weight: 500; }

/* ---------- Samples ---------- */
.samples { margin-top: 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.samples-label { font-size: 14px; font-weight: 700; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px; font-weight: 700; color: var(--ink);
  cursor: pointer; font-family: inherit;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
}
.chip:hover { background: var(--accent-soft); transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.chip:active { transform: translate(2px, 2px); box-shadow: none; }

/* ---------- Loading / error ---------- */
.spinner { width: 38px; height: 38px; border: 4px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.state-text { color: var(--muted); font-size: 15px; margin: 0; font-weight: 600; }

.card {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-hard);
  max-width: 420px; width: 100%;
}
.error-emoji { font-size: 44px; line-height: 1; }
.error-card h2 { margin: 10px 0 6px; font-size: 20px; font-weight: 900; }
.error-msg { color: var(--muted); margin: 0 0 18px; }
.error-card .btn { width: 100%; }

/* ---------- Result ---------- */
.result-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 18px; }
.recipe-hero { margin-bottom: 22px; }
.recipe-img { width: 100%; max-height: 280px; object-fit: cover; border-radius: var(--radius); border: 2px solid var(--ink); box-shadow: var(--shadow-hard); margin-bottom: 18px; }
.recipe-title { font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 6px; font-weight: 900; }
.recipe-desc { color: var(--muted); margin: 0 0 14px; font-size: 15px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; }
.meta-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 6px 13px;
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
}
.meta-chip .emoji { font-size: 15px; line-height: 1; }
.meta-chip .lbl { color: var(--muted); font-weight: 700; }

/* ---------- View toggle ---------- */
.view-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--line);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 5px;
  margin-bottom: 22px;
  box-shadow: 3px 3px 0 var(--ink);
}
.view-btn {
  border: 2px solid transparent;
  background: transparent; font-family: inherit; font-weight: 800; font-size: 15px;
  padding: 9px; border-radius: 999px; color: var(--muted); cursor: pointer; min-height: 42px;
}
.view-btn.is-active { background: var(--surface); color: var(--ink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }

/* ---------- Diagram sections ---------- */
.diagram-section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; }
.section-head .kicker { font-size: 12px; font-weight: 900; color: var(--ink); text-transform: uppercase; letter-spacing: .09em; background: var(--accent-soft); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 11px; box-shadow: 2px 2px 0 var(--ink); }
.section-head .count { font-size: 12px; font-weight: 800; color: var(--ink); background: var(--surface); border: 2px solid var(--ink); border-radius: 999px; padding: 1px 9px; }

/* ---------- Ingredient chips ---------- */
.ingredient-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ingredient-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  box-shadow: var(--shadow-hard-sm);
  min-width: 0; cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
}
.ingredient-chip:hover { transform: translate(-1px, -1px) rotate(-.5deg); box-shadow: 4px 4px 0 var(--ink); }
.ingredient-chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 2px solid var(--ink); }
.ingredient-chip .emoji { font-size: 20px; line-height: 1; flex: none; }
.ingredient-chip .text { font-size: 13.5px; line-height: 1.3; overflow: hidden; min-width: 0; font-weight: 600; }
.ingredient-chip .text b { font-weight: 800; }
.ingredient-chip .amt { color: var(--muted); }
.ingredient-chip.is-active { background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent), var(--shadow-hard-sm); }

/* ---------- Prep strip ---------- */
.prep-strip { display: flex; flex-wrap: wrap; gap: 9px; }
.prep-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--ink);
  background: var(--accent-soft);
  border: 2px dashed var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
}

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 10px; bottom: 10px; width: 3px; background: repeating-linear-gradient(to bottom, var(--ink) 0 8px, transparent 8px 16px); }
.timeline-item { position: relative; padding-left: 50px; margin-bottom: 14px; }
.timeline-dot {
  position: absolute; left: 0; top: 14px;
  width: 37px; height: 37px; border-radius: 50%;
  border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; color: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  z-index: 1;
}
.timeline-dot.prep { background: #b9ad9c; }
.timeline-dot.dish { background: var(--teal); font-size: 18px; }

/* ---------- Step cards ---------- */
.step-card {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow-hard-sm);
  transition: box-shadow .15s ease, background .15s ease;
}
.step-card.is-highlight { background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent), var(--shadow-hard-sm); }
.step-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.step-card-head h3 { margin: 0; font-size: 16px; font-weight: 900; letter-spacing: -0.01em; }
.step-num { font-size: 12px; color: var(--muted); font-weight: 800; flex: none; }
.step-head-meta { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.step-time {
  font-size: 12px; font-weight: 800; color: var(--ink);
  background: var(--accent-soft);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
  box-shadow: 2px 2px 0 var(--ink);
}
.step-text { margin: 8px 0 0; font-size: 14.5px; color: #4a3a44; font-weight: 500; }
.step-uses { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.use-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 700;
  border-radius: 999px; padding: 4px 11px;
  border: 2px solid var(--ink);
  background: var(--bg); color: var(--ink);
}
.use-chip .emoji { font-size: 14px; }
.prev-chip { border-style: dashed; color: var(--muted); background: transparent; }

/* ---------- Dish card ---------- */
.dish-card {
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-hard);
}
.dish-card h3 { margin: 0; font-size: 18px; font-weight: 900; }
.dish-card p { margin: 4px 0 0; opacity: .9; font-size: 14px; font-weight: 600; }

/* ---------- Table view ---------- */
.table-note { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 12px; }
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-hard-sm);
}
.recipe-table { border-collapse: collapse; width: 100%; min-width: 540px; font-size: 13px; }
.recipe-table th, .recipe-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.recipe-table thead th { background: var(--accent-soft); font-size: 12.5px; font-weight: 800; }
.recipe-table .ing-cell { white-space: nowrap; font-weight: 700; }
.recipe-table .ing-cell .emoji { margin-right: 6px; }
.recipe-table .ing-cell .amt { color: var(--muted); }
.recipe-table td.used { text-align: center; color: var(--coral); font-size: 15px; }
.recipe-table tr:last-child td { border-bottom: none; }
.table-dish {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 900;
  margin-top: 14px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-hard-sm);
}

/* ---------- Cooking-for-Engineers table ---------- */
.ce-table { min-width: 320px; }
.ce-table td { border: 1px solid var(--line); padding: 9px 11px; }
.ce-table .ce-prep {
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  background: var(--accent-soft);
  font-size: 13px;
  border-color: var(--line);
}
.ce-table .ing-cell { font-size: 13px; }
.ce-table td.ce-op {
  text-align: center;
  vertical-align: middle;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  white-space: nowrap;
}
.ce-table td.ce-op.vertical {
  writing-mode: vertical-rl;
  white-space: nowrap;
  padding: 14px 8px;
  letter-spacing: .05em;
  min-width: 30px;
}
.ce-table td.righthide { border-color: transparent; background: transparent; }

/* ---------- Fineprint ---------- */
.fineprint { font-size: 12.5px; color: var(--muted); margin-top: 30px; text-align: center; font-weight: 600; }

/* ---------- Wide screens ---------- */
@media (min-width: 700px) {
  .hero h1 { font-size: 46px; padding-right: 96px; }
  .ingredient-grid { grid-template-columns: repeat(3, 1fr); }
  .paste-row { display: flex; gap: 10px; }
  .paste-row .url-field { flex: 1; }
  .paste-row .btn-submit { width: auto; margin-top: 0; flex: none; }
  .recipe-img { max-height: 340px; }
}
