/* ============================================================
   MORSEL — design tokens & shared styles
   Type scale (iOS pt): 34 display / 28 title / 22 heading /
   17 body / 15 secondary / 13 caption / 11 micro
   Spacing: 4pt base — 4 / 8 / 12 / 16 / 20 / 24 / 32
   ============================================================ */

.morsel-app {
  /* Direction A — "Toast": cream + terracotta + Lora serif */
  --paper: #F7F1E6;
  --surface: #FFFCF5;
  --sunken: #EFE6D6;
  --ink: #26190E;
  --ink-2: rgba(38, 25, 14, 0.62);
  --ink-3: rgba(38, 25, 14, 0.40);
  --line: rgba(38, 25, 14, 0.10);
  --accent: #C2492B;
  --accent-ink: #FFF6EC;
  --glass: rgba(28, 18, 10, 0.34);
  --glass-text: #FFF9F0;
  --r: 22px;
  --font-display: "Lora", Georgia, serif;
  --font-ui: "Hanken Grotesk", -apple-system, "SF Pro Text", sans-serif;
  --display-weight: 600;
  --shadow-card: 0 1px 2px rgba(38,25,14,.05), 0 8px 28px rgba(38,25,14,.10);
  --shadow-float: 0 2px 6px rgba(38,25,14,.12), 0 14px 40px rgba(38,25,14,.22);
  --ts: 1; /* v3: Dynamic Type multiplier (100% = 1) */

  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Direction B — "Saffron": all-grotesque, golden accent, squarer, denser */
.morsel-app[data-dir="saffron"] {
  --paper: #FBF8F1;
  --surface: #FFFFFF;
  --sunken: #F1ECDF;
  --ink: #1F1A12;
  --ink-2: rgba(31, 26, 18, 0.60);
  --ink-3: rgba(31, 26, 18, 0.38);
  --line: rgba(31, 26, 18, 0.10);
  --accent: #C97C1B;
  --accent-ink: #FFF9EE;
  --r: 14px;
  --font-display: "Hanken Grotesk", -apple-system, sans-serif;
  --display-weight: 800;
}

/* Direction C — "Charred": after dark, photos glow */
.morsel-app[data-dir="charred"] {
  --paper: #171210;
  --surface: #221B16;
  --sunken: #2B221C;
  --ink: #F4ECDF;
  --ink-2: rgba(244, 236, 223, 0.62);
  --ink-3: rgba(244, 236, 223, 0.40);
  --line: rgba(244, 236, 223, 0.12);
  --accent: #E2603A;
  --accent-ink: #FFF6EC;
  --glass: rgba(10, 6, 3, 0.42);
  --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.4);
  --shadow-float: 0 2px 6px rgba(0,0,0,.4), 0 14px 40px rgba(0,0,0,.55);
}

.morsel-app * { box-sizing: border-box; margin: 0; }
.morsel-app img { display: block; }
.morsel-app :where(button) {
  font-family: var(--font-ui); border: none; background: none;
  color: inherit; cursor: pointer; padding: 0; text-align: inherit;
}

/* ---- type helpers (scaled by --ts for Dynamic Type) ---- */
.m-display { font-family: var(--font-display); font-weight: var(--display-weight); font-size: calc(34px * var(--ts)); line-height: 1.05; letter-spacing: -0.01em; }
.m-title   { font-family: var(--font-display); font-weight: var(--display-weight); font-size: calc(28px * var(--ts)); line-height: 1.1; letter-spacing: -0.01em; }
.m-heading { font-family: var(--font-display); font-weight: var(--display-weight); font-size: calc(22px * var(--ts)); line-height: 1.15; }
.m-body    { font-size: calc(17px * var(--ts)); line-height: 1.45; }
.m-second  { font-size: calc(15px * var(--ts)); line-height: 1.4; }
.m-caption { font-size: calc(13px * var(--ts)); line-height: 1.35; }
.m-micro   { font-size: calc(11px * var(--ts)); line-height: 1.3; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }

/* ---- screen scaffold ---- */
.m-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }
.m-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.m-scroll::-webkit-scrollbar { display: none; }

/* ---- glass chrome over photos ---- */
.m-glass {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--glass); color: var(--glass-text);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.01em;
}
.m-glass-icon {
  width: 40px; height: 40px; padding: 0;
  justify-content: center; flex: none;
}

/* ---- buttons ---- */
.m-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; font-weight: 700; font-size: calc(16px * var(--ts));
  min-height: 52px; padding: 0 24px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.m-btn:active { transform: scale(0.97); }
.m-btn-primary { background: var(--accent); color: var(--accent-ink); }
.m-btn-quiet { background: var(--sunken); color: var(--ink); }
.m-btn[disabled] { opacity: 0.35; pointer-events: none; }

/* ---- photo cards ---- */
.m-photo {
  position: relative; overflow: hidden; border-radius: var(--r);
  background: var(--sunken); width: 100%;
  transition: transform 0.18s ease;
}
.m-photo:active { transform: scale(0.97); }
.m-photo > img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }

/* gradient veil for text-on-photo */
.m-veil {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(12,7,3,0.72) 0%, rgba(12,7,3,0.18) 36%, rgba(12,7,3,0) 55%);
  pointer-events: none;
}

/* ---- tab bar ---- */
.m-tabbar {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px; padding: 5px; z-index: 40;
  box-shadow: var(--shadow-float);
}
.m-tab {
  width: 52px; height: 46px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 249, 240, 0.66);
  transition: background 0.18s ease, color 0.18s ease;
}
.m-tab[data-active="true"] { background: rgba(255, 249, 240, 0.94); color: #26190E; }

/* ---- chips ---- */
.m-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink);
  padding: 10px 18px; font-size: 15px; font-weight: 600;
  transition: all 0.15s ease; min-height: 44px;
}
.m-chip[data-on="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---- v3: keyboard focus, skeletons, warnings, banners ---- */
.morsel-app :where(button, input, a):focus-visible {
  outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px;
}
@keyframes m-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.m-skel {
  background: linear-gradient(100deg, var(--sunken) 40%, rgba(255,255,255,0.45) 50%, var(--sunken) 60%);
  background-size: 200% 100%;
  animation: m-shimmer 1.4s linear infinite;
  border-radius: calc(var(--r) * 0.8);
}
.m-warnchip {
  position: absolute; top: 8px; left: 8px;
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; padding: 5px 10px;
  font-size: calc(11.5px * var(--ts)); font-weight: 800; white-space: nowrap;
}
.m-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 14px 0; padding: 11px 14px;
  border-radius: 16px; background: var(--sunken);
  border: 1px solid var(--line);
}

/* ---- shared-element zoom (tapped photo -> detail hero) ---- */
@keyframes m-zoom {
  from {
    left: var(--zx); top: var(--zy); width: var(--zw); height: var(--zh);
    border-radius: calc(var(--r) * 0.8); opacity: 1;
  }
  82% { opacity: 1; }
  to { left: 0; top: 0; width: 100%; height: 440px; border-radius: 0; opacity: 0; }
}
.m-zoom {
  position: absolute; overflow: hidden; pointer-events: none;
  left: 0; top: 0; width: 100%; height: 440px; opacity: 0;
  animation: m-zoom 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ---- transitions: transform-only so paused/printed states stay visible ---- */
@keyframes m-rise { from { transform: translateY(14px); } to { transform: translateY(0); } }
@keyframes m-fade { from { transform: scale(0.99); } to { transform: scale(1); } }
.m-rise { animation: m-rise 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.m-fade { animation: m-fade 0.25s ease both; }
@media (prefers-reduced-motion: reduce) { .m-rise, .m-fade, .m-skel { animation: none; } .m-zoom { display: none; } }
