/* === Ezoshika Traceability — Public Landing === */
:root {
  --primary: #2E7D32;
  --primary-dark: #1B5E20;
  --primary-light: #C8E6C9;
  --accent: #8D6E63;        /* warm brown */
  --accent-dark: #5D4037;
  --bg: #FAF8F4;            /* off-white, natural */
  --surface: #FFFFFF;
  --text: #1F2D1A;
  --muted: #6B7268;
  --border: #E5E2DA;
  --danger: #C62828;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 6px rgba(31, 45, 26, 0.06), 0 1px 2px rgba(31, 45, 26, 0.08);
  --shadow-lg: 0 8px 24px rgba(31, 45, 26, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', 'Noto Sans SC', -apple-system, BlinkMacSystemFont,
    'Hiragino Kaku Gothic ProN', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary-dark); }

/* === Top bar === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
  padding-top: max(10px, env(safe-area-inset-top));
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
}
.brand-mark { font-size: 22px; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }

.lang-switch {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}
.lang-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  font-size: 12px;
  padding: 5px 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: inherit;
  transition: background 120ms ease, transform 80ms ease;
}
.lang-btn:hover { background: rgba(255,255,255,0.22); }
.lang-btn:active { transform: scale(0.96); }
.lang-btn.is-active {
  background: #fff;
  color: var(--primary-dark);
  border-color: #fff;
  font-weight: 700;
}
.lang-btn span { font-size: 11px; }

/* === Page === */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

/* === States === */
.state {
  text-align: center;
  padding: 48px 16px;
}
.state-icon { font-size: 56px; margin-bottom: 8px; }
.state h2 { margin: 8px 0 4px; }
.hidden { display: none !important; }

.demo-banner {
  background: linear-gradient(135deg, #FFF8E1 0%, #FFE0B2 100%);
  border: 1px solid #FFB74D;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(255,152,0,0.18);
}
.demo-banner .demo-icon { font-size: 26px; flex-shrink: 0; }
.demo-banner .demo-text {
  flex: 1;
  font-size: 12.5px;
  line-height: 1.5;
  color: #5D4037;
}
.demo-banner .demo-text strong {
  display: block;
  color: #E65100;
  font-size: 14px;
  margin-bottom: 3px;
  font-weight: 700;
}
.demo-banner .demo-back {
  background: #fff;
  border: 1px solid #FFB74D;
  border-radius: 6px;
  padding: 8px 12px;
  text-decoration: none;
  color: #E65100;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s;
}
.demo-banner .demo-back:hover {
  background: #FF9800;
  color: #fff;
  border-color: #FF9800;
}
@media (max-width: 540px) {
  .demo-banner { flex-direction: column; align-items: stretch; }
  .demo-banner .demo-back { align-self: flex-start; }
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Certificate === */
.cert-header {
  text-align: center;
  padding: 16px 8px 20px;
}
.cert-title {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.02em;
  color: var(--primary-dark);
  position: relative;
  display: inline-block;
  padding: 0 0 6px;
}
.cert-title::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 48px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}
.cert-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}
.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 17px;
  color: var(--primary-dark);
}
.card-title.centered { justify-content: center; }
.card-title .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.subhead {
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--accent-dark);
  font-weight: 700;
}

/* Definition list as labeled rows */
.kv {
  display: grid;
  grid-template-columns: 38% 1fr;
  gap: 6px 12px;
  margin: 0;
}
.kv.compact { grid-template-columns: 40% 1fr; }
.kv dt {
  font-size: 13px;
  color: var(--muted);
  align-self: start;
}
.kv dd {
  margin: 0;
  font-size: 15px;
  word-break: break-word;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: #F2F0EA;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}
.small { font-size: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.link { color: var(--primary-dark); margin-left: 6px; white-space: nowrap; }

/* QR */
.qr-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 0 14px;
}
#qr-canvas {
  width: 180px !important;
  height: 180px !important;
  background: #fff;
  border: 8px solid #fff;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* Photo */
.photo-wrap {
  margin: 0 0 12px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #EAE6DB;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Parts table */
.parts-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  font-size: 14px;
}
.parts-table th,
.parts-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}
.parts-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #F8F6F0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.parts-table td:last-child,
.parts-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.parts-table tbody tr:last-child td { border-bottom: none; }

/* Trust card */
.card-trust {
  background: linear-gradient(180deg, #F1F8E9 0%, #FFF 100%);
  border-color: var(--primary-light);
  text-align: center;
}
.card-trust .trust-icon { font-size: 38px; margin-bottom: 4px; }
.card-trust p { color: var(--text); font-size: 14px; }
.card-trust .kv {
  text-align: left;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--primary-light);
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px 16px max(28px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}
.footer p { margin: 4px 0; }

/* Small phones */
@media (max-width: 360px) {
  .brand-name { display: none; }
  .lang-btn span { display: none; }
  .kv { grid-template-columns: 44% 1fr; }
  #qr-canvas { width: 150px !important; height: 150px !important; }
}

/* Tablet+ */
@media (min-width: 720px) {
  .page { padding: 24px 24px 60px; }
  .cert-title { font-size: 30px; }
  .card { padding: 20px; }
  .card-title { font-size: 19px; }
}
