/* Johnny Cake Calculator — Caribbean warmth, kitchen-print friendly */

:root {
  --sand: #f6efe4;
  --sand-2: #efe4d1;
  --paper: #fffdf8;
  --ink: #241a11;
  --ink-2: #4a3826;
  --muted: #7a6a55;
  --line: #e2d3ba;
  --line-2: #cdbb9c;
  --terra: #b8451f;
  --terra-2: #8a3417;
  --sea: #2a6b6b;
  --gold: #c68a2a;
  --accent-tint: #f2e2c9;

  --radius: 14px;
  --radius-sm: 8px;

  --shadow-sm: 0 1px 2px rgba(36, 26, 17, 0.06);
  --shadow-md: 0 6px 20px -8px rgba(36, 26, 17, 0.14), 0 2px 4px rgba(36, 26, 17, 0.05);

  --font-body: "General Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--sand);
  color: var(--ink);
  font-family: var(--font-body);
  font-feature-settings: "ss01", "ss02";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.55;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 32px);
}

/* ---------- Header ---------- */
.masthead {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}
.logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(36, 26, 17, 0.10));
}
.brand-name { font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; text-transform: uppercase; }

.print-actions { display: flex; gap: 8px; }

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--terra); color: #fff; }
.btn-primary:hover { background: var(--terra-2); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--sand-2); }

/* ---------- Hero ---------- */
.hero {
  padding: 40px 0 24px;
  max-width: 780px;
}
.hero h1 {
  font-size: clamp(28px, 3.6vw, 40px);
  line-height: 1.1;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.lede {
  font-size: clamp(15px, 1.4vw, 17px);
  color: var(--ink-2);
  max-width: 62ch;
  margin: 0;
}

/* ---------- Controls ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.control-card { padding: 22px; }
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.field label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--ink);
}
.input-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-row:focus-within {
  border-color: var(--terra);
  box-shadow: 0 0 0 3px rgba(184, 69, 31, 0.12);
}
.input-row input {
  flex: 1;
  border: 0;
  outline: none;
  padding: 10px 12px;
  font: inherit;
  font-variant-numeric: tabular-nums;
  background: transparent;
  color: var(--ink);
  min-width: 0;
}
.input-row .unit {
  padding: 10px 12px;
  background: var(--sand-2);
  color: var(--muted);
  font-size: 13px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
select {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
select:focus {
  outline: none;
  border-color: var(--terra);
  box-shadow: 0 0 0 3px rgba(184, 69, 31, 0.12);
}
.hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Summary strip ---------- */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 24px 0 24px;
}
.stat {
  background: var(--accent-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  font-weight: 600;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--terra-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ---------- Output docs ---------- */
.output-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}
@media (min-width: 960px) {
  .output-grid { grid-template-columns: 1fr 1.05fr; }
}
.doc { padding: 28px; }
.doc-head { margin-bottom: 18px; }
.doc-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.doc-mark {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
}
.doc-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sea);
  background: rgba(42, 107, 107, 0.08);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.doc h2 {
  font-size: 22px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.doc-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.ingredient-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}
.ingredient-table th,
.ingredient-table td {
  padding: 10px 8px;
  border-bottom: 1px dashed var(--line);
  vertical-align: baseline;
  font-size: 14.5px;
}
.ingredient-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
}
.ingredient-table td.num,
.ingredient-table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.ingredient-table .grams { font-weight: 500; color: var(--terra-2); }
.ingredient-table .ing-name { font-weight: 600; }
.ingredient-table .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.ingredient-table.compact th,
.ingredient-table.compact td { padding: 8px 6px; font-size: 14px; }

/* Grouped batch card: dry / fat / wet phases */
.ingredient-table tr.group-head td {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--ink);
  padding-top: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-2);
}
.ingredient-table tr.group-head td.num {
  font-family: var(--font-mono);
  color: var(--terra-2);
}
.ingredient-table tr.group-head td.num + td.num {
  color: var(--muted);
  font-weight: 500;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.ingredient-table tr.group-head.g-dry td:first-child { border-left: 3px solid var(--gold); padding-left: 10px; }
.ingredient-table tr.group-head.g-fat td:first-child { border-left: 3px solid var(--terra); padding-left: 10px; }
.ingredient-table tr.group-head.g-wet td:first-child { border-left: 3px solid var(--sea); padding-left: 10px; }

.ingredient-table tr.group-total td {
  padding-top: 14px;
  border-top: 2px solid var(--ink);
  border-bottom: 0;
  font-weight: 700;
  font-size: 14px;
}
.ingredient-table tr.group-total td.grams {
  color: var(--terra-2);
  font-size: 15px;
}

.doc-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-2);
}

/* Batch card ------- */
.batch-header {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  background: var(--sand-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
}
@media (min-width: 500px) {
  .batch-header { grid-template-columns: repeat(4, 1fr); }
}
.batch-cell { display: flex; flex-direction: column; gap: 2px; }
.batch-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 600;
}
.batch-value {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
  font-size: 14px;
}
.batch-h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sea);
  font-weight: 700;
  margin: 20px 0 8px;
}
.method {
  padding-left: 22px;
  margin: 0;
}
.method li {
  padding: 5px 0;
  color: var(--ink-2);
  font-size: 14.5px;
}
.method li::marker { color: var(--terra); font-weight: 700; }
.batch-notes ul {
  padding-left: 20px;
  margin: 0;
}
.batch-notes li {
  padding: 4px 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

/* ---------- Pricing ---------- */
.pricing {
  margin-top: 28px;
  padding: 26px;
}
.pricing-head {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.pricing h2 {
  font-size: 20px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.pricing-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  max-width: 62ch;
}
.pricing-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.cur-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.cur-toggle select {
  width: auto;
  padding: 6px 10px;
  font-size: 13px;
}
.btn-sm { padding: 7px 14px; font-size: 13px; }

.price-table {
  width: 100%;
  border-collapse: collapse;
}
.price-table th,
.price-table td {
  padding: 10px 8px;
  border-bottom: 1px dashed var(--line);
  vertical-align: baseline;
  font-size: 14px;
}
.price-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
}
.price-table th.num,
.price-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.price-table tfoot td {
  padding-top: 14px;
  border-top: 2px solid var(--ink);
  border-bottom: 0;
  font-weight: 700;
  font-size: 14px;
}
.price-table tfoot td.num:last-child {
  color: var(--terra-2);
  font-size: 16px;
}
.price-edit {
  display: inline-block;
  min-width: 44px;
  padding: 3px 6px;
  border: 1px dashed var(--line-2);
  border-radius: 4px;
  background: #fff;
  cursor: text;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.price-edit:hover { border-color: var(--terra); background: var(--sand); }
.price-edit:focus {
  outline: none;
  border-color: var(--terra);
  border-style: solid;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(184, 69, 31, 0.12);
}
.unit-sm {
  margin-left: 4px;
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.pricing-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 18px 32px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.pricing-foot strong {
  font-family: var(--font-mono);
  color: var(--terra-2);
  font-weight: 500;
  font-size: 15px;
}

.cost-stat .stat-value { color: var(--sea); }
.stat-sub {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Labor panel ---------- */
.labor-panel {
  margin-top: 18px;
  padding: 18px 18px 14px;
  background: var(--sand);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.labor-title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--terra-2);
}
.labor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 20px;
}
.labor-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-2);
}
.labor-field > span {
  font-weight: 500;
  line-height: 1.3;
}
.labor-input {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 6px 10px;
}
.labor-input:focus-within {
  border-color: var(--terra);
  box-shadow: 0 0 0 3px rgba(184, 69, 31, 0.12);
}
.labor-input input {
  border: 0;
  padding: 0;
  width: 100%;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  outline: none;
  min-width: 0;
}
.labor-input input::-webkit-outer-spin-button,
.labor-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.labor-input input[type=number] { -moz-appearance: textfield; }
.labor-out {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  font-size: 13px;
  color: var(--ink-2);
}
.labor-out strong {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--terra-2);
  font-size: 14.5px;
}

/* ---------- Reference ---------- */
.reference { margin: 32px 0 24px; }
.reference details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 20px;
}
.reference summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  padding: 4px 0;
  list-style: none;
}
.reference summary::-webkit-details-marker { display: none; }
.reference summary::before {
  content: "+";
  display: inline-block;
  width: 18px;
  color: var(--terra);
  font-family: var(--font-mono);
  font-weight: 700;
}
.reference details[open] summary::before { content: "−"; }
.ref-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}
.ref-grid h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sea);
  margin: 0 0 8px;
  font-weight: 700;
}
.ref-grid ul {
  margin: 0; padding-left: 18px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.ref-grid li { padding: 2px 0; }
.ref-grid a { color: var(--terra-2); }

/* ---------- Footer ---------- */
.site-foot {
  margin: 40px 0 60px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .masthead, .hero, .controls, .summary, .reference, .site-foot, .print-actions, .pricing { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .output-grid { display: block; }
  .doc {
    box-shadow: none;
    border: none;
    padding: 0 0 32px;
    page-break-after: always;
  }
  .doc:last-child { page-break-after: auto; }
  .doc h2 { font-size: 20px; margin-top: 6px; }
  .ingredient-table th, .ingredient-table td { padding: 6px 4px; font-size: 12px; }
  .batch-h3 { color: #000; }
  .doc-tag { background: transparent; padding-left: 0; }
  .doc-brand { margin-bottom: 6px; }
  .doc-mark { width: 48px; height: 48px; }
  .logo, .doc-mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
