/* SubsDiet — styles.css
   Mobile-first, single accent color, no frameworks, no CDN.
   Accent: #6366f1 (indigo)
*/

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:      #6366f1;
  --accent-dark: #4f46e5;
  --accent-lt:   #818cf8;
  --bg:          #0f172a;
  --bg-card:     #1e293b;
  --bg-card2:    #0f1a2e;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --border:      #334155;
  --green:       #22c55e;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
}

html { scroll-behavior: smooth; }

body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

/* Reserve space so the fixed sticky bar never covers the footer/last content. */
body.sticky-active { padding-bottom: 96px; }

a { color: var(--accent-lt); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Header ===== */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-lt);
  letter-spacing: -0.5px;
}

.site-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 56px 16px 40px;
}

.hero-title {
  font-size: clamp(1.8rem, 6vw, 3rem);
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -1px;
}

.hero-title .accent { color: var(--accent-lt); }

.hero-subtitle {
  font-size: clamp(0.95rem, 3vw, 1.15rem);
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 28px;
}

.btn-hero {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 14px 36px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
  letter-spacing: 0.2px;
}
.btn-hero:hover { background: var(--accent-dark); transform: translateY(-1px); }

/* ===== Selection Section ===== */
.selection-section { padding: 24px 0 40px; }

.section-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-lt);
  margin-bottom: 20px;
}

/* ===== Category ===== */
.category-section { margin-bottom: 36px; }

.category-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin-bottom: 14px;
}

.chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* ===== Product Card ===== */
.product-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.product-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.product-card.selected {
  border-color: var(--accent);
  background: rgba(99,102,241,.08);
}

.product-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  width: 100%;
}

.product-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin-top: 3px;
  flex-shrink: 0;
  cursor: pointer;
}

.product-name {
  font-weight: 700;
  font-size: 0.97rem;
  flex: 1;
}

.product-plan {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.product-price-badge {
  font-size: 0.8rem;
  color: var(--accent-lt);
  white-space: nowrap;
  font-weight: 600;
  margin-top: 2px;
}

/* ===== Price Edit Row ===== */
.price-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.price-edit-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.price-edit-input {
  width: 100px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  padding: 4px 8px;
  text-align: right;
}
.price-edit-input:focus { outline: 2px solid var(--accent); }

.price-edit-unit {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== Sticky bar ===== */
/* Fixed to the viewport bottom so the live total + CTA is always visible while
   choosing (sticky+bottom only pins once the bar scrolls into view). */
#sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
  justify-content: space-between;
}

.sticky-info { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.sticky-count { font-size: 0.9rem; color: var(--text-muted); }
.sticky-total { font-size: 0.9rem; color: var(--text); font-weight: 600; }
.sticky-savings { font-size: 0.9rem; color: var(--accent-lt); font-weight: 700; }

.btn-diagnose {
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 28px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-diagnose:hover { background: var(--accent-dark); }
.btn-diagnose:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; }

/* ===== Result Section ===== */
#result-section {
  padding: 40px 0 60px;
}

.result-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 36px 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}

.result-label {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-savings-heading {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.result-savings-amount {
  font-size: clamp(2.8rem, 10vw, 5rem);
  font-weight: 900;
  color: var(--accent-lt);
  line-height: 1.1;
  letter-spacing: -2px;
  margin-bottom: 4px;
}

.result-savings-unit {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.result-annual-row {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.result-type-box {
  background: rgba(99,102,241,.1);
  border: 1px solid rgba(99,102,241,.3);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-top: 16px;
}

.result-type-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.result-type-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-lt);
}

.result-type-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Alt Table ===== */
.alt-table-section { margin-bottom: 28px; }

.alt-table-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

/* The container handles horizontal scrolling so the table can stay a real
   table element (predictable column widths across browsers). */
#alt-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.alt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.alt-table th {
  background: var(--bg-card2);
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.alt-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.alt-table tr:last-child td { border-bottom: none; }

.alt-link { color: var(--accent-lt); font-weight: 600; }
.alt-link:hover { text-decoration: underline; }

.badge-free {
  display: inline-block;
  background: rgba(34,197,94,.15);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  border: 1px solid rgba(34,197,94,.3);
}

.td-savings { color: var(--accent-lt); font-weight: 700; white-space: nowrap; }
.td-note    { color: var(--text-muted); font-size: 0.82rem; max-width: 240px; }
.td-muted   { color: var(--text-muted); font-size: 0.82rem; }
.source-link { color: var(--text-muted); font-size: 0.75rem; text-decoration: underline; }
.source-link:hover { color: var(--accent-lt); }

.no-alt {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 16px 0;
}

/* ===== Caveat ===== */
.caveat-note {
  background: rgba(148,163,184,.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ===== Share Section ===== */
.share-section { margin-bottom: 28px; }

.share-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

#share-card-preview {
  display: none;
  width: 100%;
  max-width: 560px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

#share-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.share-btn {
  padding: 10px 20px;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 700;
  transition: opacity 0.15s, transform 0.1s;
}
.share-btn:hover { opacity: 0.85; transform: translateY(-1px); }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg-card2); color: var(--text); border: 1px solid var(--border); }
.btn-x         { background: #000; color: #fff; border: 1px solid #333; }
.btn-line      { background: #06c755; color: #fff; }

/* ===== Share text variant chooser ===== */
.share-variant-chooser {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.share-variant-label {
  width: 100%;
  margin: 0 0 2px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}
.btn-variant {
  padding: 6px 14px;
  font-size: 0.85rem;
  background: var(--bg-card2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-variant.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.share-variant-preview {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-card2);
  color: var(--text);
  font-size: 0.85rem;
  white-space: pre-wrap;
  line-height: 1.5;
}
.share-image-notice {
  width: 100%;
  margin: 0 0 4px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  font-size: 0.82rem;
}

/* ===== Retry Button ===== */
.retry-wrap { text-align: center; margin-top: 16px; }
.btn-retry {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 10px 24px;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s;
}
.btn-retry:hover { border-color: var(--accent); color: var(--text); }

/* ===== Footer ===== */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 40px 0 28px;
  margin-top: 40px;
}

.footer-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 640px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
}

.footer-block h4 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.footer-block p,
.footer-block li {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.footer-block ul { padding-left: 0; list-style: none; }
.footer-block a { color: var(--text-muted); text-decoration: underline; }
.footer-block a:hover { color: var(--text); }

.footer-bottom {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Responsive tweaks ===== */
@media (max-width: 480px) {
  .chips-grid { grid-template-columns: 1fr; }
  .result-card { padding: 24px 16px; }
  .alt-table th, .alt-table td { padding: 8px; }
  .td-note { max-width: 120px; }
  #sticky-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .btn-diagnose { width: 100%; text-align: center; }
}

@media (min-width: 640px) {
  .chips-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
