/* ============================================================
   style.css — Nutrition Facts Label Practice
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }

body {
  min-height: 100dvh;
  background: #e8e6e1;
  font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
  gap: 20px;
}

.page-header {
  text-align: center;
  max-width: 420px;
  padding: 0 8px;
}
.page-header h1 {
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.page-header p {
  font-size: clamp(0.78rem, 2.5vw, 0.85rem);
  color: #555;
  line-height: 1.5;
}

.btn-new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 22px;
  font-size: clamp(0.82rem, 2.5vw, 0.9rem);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  letter-spacing: 0.01em;
}
.btn-new:hover { background: #333; }
.btn-new:active { background: #000; }
.btn-new svg { flex-shrink: 0; }

@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position: 600px 0; }
}
.skeleton-label {
  width: min(340px, calc(100vw - 32px));
  border: 2px solid #000;
  padding: 6px;
  background: #fff;
}
.skel {
  background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 2px;
}
.skel-title { height: 52px; margin-bottom: 8px; }
.skel-line { height: 14px; margin-bottom: 6px; }
.skel-thick { height: 8px; margin-bottom: 8px; background: #ccc; }
.skel-lg { height: 44px; margin-bottom: 8px; }
.skel-sm { width: 60%; height: 12px; margin-bottom: 5px; }

.error-box {
  width: min(340px, calc(100vw - 32px));
  border: 2px solid #c00;
  padding: 16px;
  background: #fff;
  border-radius: 4px;
  color: #c00;
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.5;
}

.product-bar {
  width: min(340px, calc(100vw - 32px));
  background: #fff;
  border: 2px solid #000;
  border-radius: 0;
  padding: 10px 12px;
  font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
  font-size: 13pt;
  color: #222;
  text-align: center;
  line-height: 1.6;
}
.product-bar .prod-name {
  font-weight: 700;
  font-size: 14pt;
  display: block;
  margin-bottom: 2px;
}
.product-bar .prod-brand {
  color: #444;
  font-size: 13pt;
}
.product-bar .prod-category {
  color: #777;
  font-size: 11pt;
  display: block;
}

.product-image-wrap {
  width: 100%;
  background: transparent;
  border: none;
  border-top: 1px solid #ccc;
  margin-top: 10px;
  padding-top: 10px;
  text-align: center;
}
.product-image-wrap img {
  max-width: 180px;
  max-height: 180px;
  width: auto;
  height: auto;
  display: block;
  margin: 0 auto 8px;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: opacity 0.15s;
}
.product-image-wrap img:hover { opacity: 0.85; }
.product-image-wrap .img-credit {
  font-size: 7.5pt;
  color: #555;
  line-height: 1.4;
}
.product-image-wrap .img-credit a {
  color: #01696f;
  text-decoration: underline;
}
.product-image-wrap .img-missing {
  font-size: 8pt;
  color: #999;
  padding: 8px 0;
}
.product-image-wrap .img-missing a {
  color: #01696f;
  text-decoration: underline;
}

:root {
  --label-scale: 1;
  --label-natural-height: 620px;
}
.label-scaler {
  transform: scale(var(--label-scale));
  transform-origin: top center;
  margin-bottom: calc((var(--label-scale) - 1) * var(--label-natural-height));
}

.nfl-wrap { width: 480px; }

.nfl {
  border: 2px solid #000;
  padding: 4px 6px;
  background: #fff;
  color: #000;
  font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
  font-size: 14pt;
  line-height: 1.2;
}

.nfl-title {
  font-size: 52pt;
  font-weight: 900;
  line-height: 0.87;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.nfl-servings-per { font-size: 12pt; margin-top: 1px; }

.nfl-serving-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13pt;
  font-weight: 700;
  margin-top: 1px;
}

.nfl-bar-thick { height: 9px; background: #000; margin: 3px 0; }
.nfl-bar-medium { height: 4px; background: #000; margin: 2px 0; }
.nfl-bar-thin { height: 1px; background: #000; margin: 0; }

.nfl-amount-label { font-size: 11pt; font-weight: 700; margin-top: 2px; }

.nfl-calories-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: -1px;
}
.nfl-calories-label { font-size: 32pt; font-weight: 700; line-height: 1; }
.nfl-calories-value {
  font-size: 65pt;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.03em;
}

.nfl-dv-header {
  text-align: right;
  font-size: 11pt;
  font-weight: 700;
  margin-top: 3px;
  margin-bottom: 1px;
}

.nfl-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1.5px 0;
  border-top: 1px solid #000;
}
.nfl-row:first-child { border-top: none; }
.nfl-row-label { flex: 1; }
.nfl-row-value { white-space: nowrap; margin-left: 4px; }
.nfl-row-dv {
  white-space: nowrap;
  margin-left: 6px;
  font-weight: 700;
  min-width: 34px;
  text-align: right;
}

.nfl-bold { font-weight: 700; }
.nfl-indent1 { padding-left: 12px; }
.nfl-indent2 { padding-left: 24px; }
.nfl-italic { font-style: italic; }

.nfl-micros { margin-top: 0; }
.nfl-micro-row {
  display: flex;
  justify-content: space-between;
  padding: 1.5px 0;
  border-top: 1px solid #000;
  font-size: 12pt;
}

.nfl-footnote {
  font-size: 9pt;
  line-height: 1.35;
  margin-top: 4px;
  border-top: 1px solid #000;
  padding-top: 3px;
}

.ingredients-box {
  width: min(480px, calc(100vw - 32px));
  border: 2px solid #000;
  background: #fff;
  padding: 6px 8px;
  font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
  font-size: 11pt;
  line-height: 1.4;
}
.ingredients-box strong { font-weight: 700; }

.credits-bar {
  width: min(480px, calc(100vw - 32px));
  background: #f7f6f2;
  border: 2px solid #000;
  border-top: none;
  padding: 7px 12px;
  font-size: 8.5pt;
  color: #555;
  line-height: 1.6;
  text-align: center;
}
.credits-bar a {
  color: #01696f;
  text-decoration: underline;
}
.credits-bar strong { color: #222; }

.fdc-chip {
  display: inline-block;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 7.5pt;
  color: #555;
  margin-top: 3px;
}

.nfl-wrap, .ingredients-box, .product-bar, .credits-bar { display: none; }
/* ── Checks & Warnings legend box ── */
.legend-box {
  display: none;
  width: min(480px, calc(100vw - 32px));
  background: #fff;
  border: 2px solid #000;
  padding: 10px 14px;
  font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
  font-size: 0.82rem;
  line-height: 1.6;
}
.legend-box.visible { display: block; }
.legend-box h3 {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 3px;
  margin-bottom: 4px;
}
.legend-row.leg-red    { background: #fde8e8; border-left: 3px solid #c0392b; }
.legend-row.leg-orange { background: #fef3e2; border-left: 3px solid #e67e22; }
.legend-row.leg-green  { background: #e9f7ef; border-left: 3px solid #27ae60; }
.legend-icon { font-size: 1.2rem; flex-shrink: 0; }
.legend-text { flex: 1; color: #222; }

/* ── Checks & Warnings highlights ── */
.flag-red    { background: #fde8e8; border-left: 3px solid #c0392b; padding-left: 3px; }
.flag-orange { background: #fef3e2; border-left: 3px solid #e67e22; padding-left: 3px; }
.flag-green  { background: #e9f7ef; border-left: 3px solid #27ae60; padding-left: 3px; }
.flag-neutral { background: #f5f5f5; }

.flag-emoji {
  margin-left: 5px;
  font-size: 16pt;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Ingredient highlights ── */
.ing-red {
  background: #fde8e8;
  border-bottom: 2px solid #c0392b;
  border-radius: 2px;
  padding: 0 2px;
  cursor: help;
}
.ing-orange {
  background: #fef3e2;
  border-bottom: 2px solid #e67e22;
  border-radius: 2px;
  padding: 0 2px;
  cursor: help;
}

/* ── Checks & Warnings legend box ── */
.legend-box {
  display: none;
  width: min(480px, calc(100vw - 32px));
  background: #fff;
  border: 2px solid #000;
  padding: 10px 14px;
  font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
  font-size: 0.82rem;
  line-height: 1.6;
}
.legend-box.visible { display: block; }
.legend-box h3 {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 3px;
  margin-bottom: 4px;
}
.legend-row.leg-red    { background: #fde8e8; border-left: 3px solid #c0392b; }
.legend-row.leg-orange { background: #fef3e2; border-left: 3px solid #e67e22; }
.legend-row.leg-green  { background: #e9f7ef; border-left: 3px solid #27ae60; }
.legend-icon { font-size: 1.2rem; flex-shrink: 0; }
.legend-text { flex: 1; color: #222; }

/* ── Author credits ── */
.author-credits {
  width: min(480px, calc(100vw - 32px));
  background: #f7f6f2;
  border: 2px solid #000;
  padding: 12px 16px;
  font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  color: #333;
  line-height: 1.7;
  text-align: center;
}
.author-credits p { margin-bottom: 6px; }
.author-credits a { color: #01696f; text-decoration: underline; }
.author-credits img { vertical-align: middle; }

.additional-resources {
  width: min(480px, calc(100vw - 32px));
  border: 2px solid #000;
  background: #fff;
  padding: 6px 8px;
  font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
  font-size: 11pt;
  line-height: 1.4;
}

/* ── Collapsible sections ── */
.collapsible-section {
  overflow: hidden;
}

.collapsible-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.collapsible-toggle:focus-visible {
  outline: 2px solid #01696f;
  outline-offset: 3px;
}

.collapsible-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.collapsible-content {
  margin-top: 8px;
}

.collapsible-section.is-collapsed .collapsible-content {
  display: none;
}

.legend-box .collapsible-toggle {
  font-size: 0.88rem;
}

.legend-box h3 {
  display: none;
}
