/* HealthyPour — application shell / layout. */

/* Turbo frames wrap layout regions (the cabinet filter, for example). A frame is
   an unknown element, so it is inline by default; `contents` keeps it out of the
   layout entirely and leaves the header/main boxes as direct children of .app. */
turbo-frame { display: contents; }

.app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------------- header ---------------- */
/* The native shells let this header run to the top of the screen, so it clears
   the status bar / notch itself. `max` rather than a sum: the inset is already
   most of the room the header needs, and adding a full --sp-6 on top of it left
   the header floating well below the native back button. Resolves to --sp-6 in a
   normal browser, where the inset is 0. */
.app-header { position: sticky; top: 0; z-index: 15; padding: max(var(--sp-6), calc(env(safe-area-inset-top) + var(--sp-2))) var(--sp-5) var(--sp-4); background: var(--bg-overlay); backdrop-filter: blur(12px); }
.app-header-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.app-header h1 { font-size: var(--fs-2xl); }
.app-header .meta-line { font-family: var(--font-mono); font-size: .6875rem; color: var(--text-3); margin-top: 6px; }
/* margin-left keeps the actions right-aligned when they're the row's only child,
   which happens where the back link is left to the native navigation bar. */
.header-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

.brand { display: inline-flex; align-items: baseline; gap: 1px; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-xl); letter-spacing: -.01em; }
.brand em { font-style: italic; color: var(--brand-primary); }

.icon-btn { width: 36px; height: 36px; border-radius: var(--r-full); border: 1px solid var(--border-default); background: var(--bg-surface); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--dur-fast); }
.icon-btn:hover { color: var(--text-1); border-color: var(--border-strong); }
.header-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-secondary); color: var(--text-inverse); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 600; font-size: var(--fs-sm); }

/* ---------------- content ---------------- */
.app-content { padding: 0 var(--sp-5) var(--sp-8); }
.page-back { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); margin: var(--sp-4) 0; }
.page-back:hover { color: var(--text-1); }

.section { margin: var(--sp-6) 0; }
.section-title { font-family: var(--font-mono); font-size: .625rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-bottom: var(--sp-3); }
.card { border: 1px solid var(--border-default); border-radius: var(--r-lg); background: var(--bg-surface); padding: var(--sp-5); }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }

/* ---------------- segmented tabs (Cabinet) ---------------- */
.segmented { display: flex; gap: var(--sp-5); border-bottom: 1px solid var(--border-subtle); margin-top: var(--sp-2); }
.seg-btn { background: none; border: none; padding: 0 0 var(--sp-3); font-size: var(--fs-sm); font-weight: 600; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--dur-fast), border-color var(--dur-fast); }
.seg-btn.active { color: var(--brand-primary); border-color: var(--brand-primary); }

/* ---------------- filter chips scroller ---------------- */
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: var(--sp-4) 0; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-row .chip { white-space: nowrap; }

/* The active tag / ingredient filter. The label and the clear link keep the
   .section-title type; the chip brings its own, so it reads as the tag pill it
   is on a recipe page rather than as more of the caption. */
.filter-summary { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin: 0 0 var(--sp-3); }
.filter-summary .chip { cursor: default; }
.filter-summary a:hover { color: var(--text-1); }

/* ---------------- floating action button ---------------- */
.fab {
  position: fixed; bottom: 88px; right: max(20px, calc(50% - 260px + 20px)); width: 54px; height: 54px; border-radius: 50%;
  background: var(--brand-primary); color: var(--text-inverse); border: none; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-md), 0 0 26px color-mix(in srgb, var(--brand-primary) 45%, transparent); cursor: pointer; z-index: 18;
  transition: transform var(--dur-fast);
}
.fab:hover { transform: scale(1.06); }

/* Hidden when a native bridge component promotes this control to the nav bar. */
.bridge-hidden { display: none !important; }

/* ---------------- bottom tab bar ---------------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg-rail); border-top: 1px solid var(--border-subtle); backdrop-filter: blur(12px); padding-bottom: env(safe-area-inset-bottom); }
.tabbar-inner { max-width: 520px; margin: 0 auto; height: 72px; display: flex; justify-content: space-around; align-items: center; }
.tab-btn { background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-3); font-family: var(--font-mono); font-size: .5625rem; letter-spacing: .02em; cursor: pointer; padding: 6px 8px; text-transform: uppercase; }
.tab-btn.active { color: var(--brand-primary); }

/* ---------------- top nav (desktop) ---------------- */
/* Hidden on mobile; the bottom tab bar handles navigation there. */
.topnav { display: none; }

@media (min-width: 768px) {
  :root { --topnav-h: 60px; }

  .topnav {
    display: block; position: sticky; top: 0; z-index: 30;
    background: var(--bg-rail); border-bottom: 1px solid var(--border-subtle); backdrop-filter: blur(12px);
  }
  .topnav-inner {
    max-width: 960px; margin: 0 auto; height: var(--topnav-h);
    display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6);
    padding: 0 var(--sp-5);
  }
  .topnav-brand .brand { font-size: var(--fs-lg); }
  .topnav-links { display: flex; align-items: center; gap: var(--sp-2); }
  .topnav-btn {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: 8px 12px; border-radius: var(--r-full);
    color: var(--text-3); font-size: var(--fs-sm); font-weight: 600;
    transition: color var(--dur-fast), background var(--dur-fast);
  }
  .topnav-btn:hover { color: var(--text-1); background: var(--bg-surface); }
  .topnav-btn.active { color: var(--brand-primary); }

  /* Bottom tab bar gives way to the top nav on wider screens. */
  .tabbar { display: none; }
  /* Page headers stick just below the top nav rather than the viewport top. */
  .app-header { top: var(--topnav-h); }
  /* No fixed bottom bar to clear anymore. */
  .app { padding-bottom: var(--sp-10); }
}

/* ---------------- auth pages ---------------- */
.auth-shell { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(var(--sp-8) + env(safe-area-inset-top)) var(--sp-5) calc(var(--sp-8) + env(safe-area-inset-bottom)); }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: var(--sp-5); }
.auth-head { text-align: center; display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; margin-bottom: var(--sp-2); }
.auth-head .brand { font-size: var(--fs-3xl); }
.auth-head p { font-size: var(--fs-sm); color: var(--text-3); }
.auth-divider { display: flex; align-items: center; gap: var(--sp-3); color: var(--text-3); font-family: var(--font-mono); font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .1em; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }
.oauth-buttons { display: flex; flex-direction: column; gap: var(--sp-3); }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); padding: 12px; border-radius: var(--r-sm); border: 1.5px solid var(--border-default); background: var(--bg-surface); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; transition: all var(--dur-fast); }
.oauth-btn:hover { border-color: var(--border-strong); background: var(--bg-surface-2); }
.auth-alt { text-align: center; font-size: var(--fs-sm); color: var(--text-3); }
.auth-alt a { color: var(--brand-primary); font-weight: 600; }
.auth-links { text-align: center; font-size: var(--fs-xs); }
.auth-links a { color: var(--text-3); }

/* ---------------- switch (theme toggle in settings) ---------------- */
.switch { --w: 38px; --h: 22px; width: var(--w); height: var(--h); border-radius: var(--r-full); border: 1px solid var(--border-strong); background: var(--bg-surface-2); position: relative; cursor: pointer; flex: none; padding: 0; transition: background var(--dur-base); }
.switch::after { content: ""; position: absolute; top: 1px; left: 1px; width: 18px; height: 18px; border-radius: 50%; background: var(--brand-secondary); box-shadow: var(--sh-sm); transition: transform var(--dur-base) var(--ease-standard); }
.switch[aria-pressed="true"]::after { transform: translateX(16px); }
