/* ============================================================================
📁 FILE: starter-store-base.css
🎨 PURPOSE: Styles for Starter Store — Header, Navbar, Hero, Products, Cart, Footer
✍️ AUTHOR: Captain & Chatman
🔄 VERSION: Phase XIII+d — Token-only shadows, dark-friendly, a11y focus
============================================================================= */

/* Colors come from theme-consume.css:
   --color_bg, --color_surface, --color_border, --color_text, --color_text_muted,
   --brand, --primary, --on_primary, --secondary, --on_secondary, --accent, --chip-*
*/

/* ========== 🔗 Token Mappings for Nav & Footer (brand-aware) ========== */
/* Only provide defaults when no explicit theme-id is active.
   This avoids overriding per-theme mappings from theme-consume.css. */
html:not([data-theme-id]) {
  /* Navbar defaults to primary */
  --navbar_bg: var(--primary);
  --on_navbar: var(--on_primary);

  /* Footer defaults to brand */
  --footer_bg: var(--brand);
  --on_footer: var(--on_primary);
}

/* ========== 🌐 Page Layout & Structure ========== */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Hide scrollbar UI on the root scrolling element as well */
html {
  -ms-overflow-style: none; /* IE/legacy Edge */
  scrollbar-width: none; /* Firefox */
}
html::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none;
}

body.storefront {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--color_bg);
  color: var(--color_text);
  overflow: hidden; /* delegate scrolling to inner container to remove body scrollbar */
  /* Hide page scrollbar UI but allow scrolling (Windows/Firefox/WebKit) */
  -ms-overflow-style: none; /* IE 10+ / legacy Edge */
  scrollbar-width: none; /* Firefox */
}

/* WebKit (Chrome, new Edge, Safari) — hide scrollbar visuals */
body.storefront::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none;
}

/* In case scrolling is on inner containers, hide their scrollbars too */
.page-shell,
.page-shell main {
  -ms-overflow-style: none; /* IE/Edge */
  scrollbar-width: none; /* Firefox */
}
.page-shell::-webkit-scrollbar,
.page-shell main::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none;
}

/* main grows before footer */
.page-shell main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 4px; /* breathing room around content */
  box-sizing: border-box;
  background-color: var(--color_bg);
  overflow-y: auto; /* this is the scroll container now */
}

/* ========== 🟦 Header Shell & Top Bar ========== */
/* Use PRIMARY for header background so it swaps with theme (dark/light) */
.header-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  margin: 0;
  line-height: 0;
  background-color: var(--header_bg);
}

.top-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px; /* change footer height*/
  background-color: var(--header_bg);
  color: var(--on_header);
  flex-wrap: wrap;
  line-height: 1;
  margin: 0;
  border-bottom: 2px solid color-mix(in oklab, var(--header_bg) 85%, black 15%);
}

.top-header-content {
  display: flex;
  align-items: center;
}

.admin-logo {
  height: 65px; /* reduced from 90px */
  margin-right: 10px;
}

.admin-console-title {
  font-size: 2rem;
  color: var(--on_header);
  font-weight: 600;
  margin-left: 20px;
}

/* ========== Stores Logo ========== */
.store-logo {
  height: 60px; /* reduced from 80px */
  width: auto;
  display: block;
  margin: 10px 6px 12px; /* reduced top/bottom margin */
}

/* ========== 🔍 Header Controls (Search + Auth) ========== */
.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* keep inputs readable on a primary header */
.header-search {
  display: flex;
  gap: 6px;
  margin-right: 20px;
}

.header-search input[type="search"] {
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--search_border);
  outline: none;
  min-width: 200px;
  font-size: 14px;
  /* slightly translucent chip on primary background for contrast */
  background: var(--search_bg);
  color: var(--on_search);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.header-search input::placeholder {
  color: var(--search_placeholder);
}

.header-search input[type="search"]:focus-visible {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.search-btn {
  font-size: 20px;
  padding: 5px 5px;
  background-color: transparent;
  color: var(--on_header);
  border: 1px solid currentColor;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.search-btn:hover {
  background-color: color-mix(
    in oklab,
    var(--on_header) 90%,
    var(--header_bg) 10%
  );
  border-color: color-mix(in oklab, var(--header_bg) 50%, transparent);
}
.search-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent);
}

/* ========== 🔐 Auth Buttons (top-right) ========== */
.nav-auth-btn {
  color: var(--on_header);
  font-weight: bold;
  background-color: transparent;
  text-decoration: none;
  padding: 10px 10px;
  border: 1px solid currentColor;
  border-radius: 5px;
  display: inline-block;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.nav-auth-btn:hover {
  background-color: color-mix(in oklab, var(--on_header) 15%, transparent);
  border-color: currentColor;
}
.nav-auth-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent);
}

/* ========== 💡 Hero Section ========== */
.hero-frame {
  padding: 10px;
  background-color: var(--color_surface);
  border: 1px solid var(--color_border);
  border-radius: 8px;
  /* token-derived soft shadow (no rgba) */
  box-shadow: 0 0 4px color-mix(in oklab, var(--color_text) 5%, transparent);
  margin: 20px auto;
  max-width: 1000px;
  box-sizing: border-box;
}

.hero {
  background-color: var(--secondary);
  text-align: center;
  padding: 20px 20px;
}
.hero h2 {
  margin: 0;
  font-size: 2rem;
  color: var(--color_text);
}
.hero p {
  font-size: 1rem;
  color: var(--color_text);
}

/* ========== 🛍️ Product Grid ========== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 20px;
  max-width: 1000px;
  margin: 0 auto;
}

.product {
  background: var(--color_surface);
  border: 1px solid var(--color_border);
  border-radius: 6px;
  padding: 16px;
  text-align: center;
  /* token-derived soft shadow (no rgba) */
  box-shadow: 0 1px 4px color-mix(in oklab, var(--color_text) 6%, transparent);
  color: var(--color_text);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.product h3 {
  margin-top: 0;
  color: var(--color_text);
}
.product button {
  margin-top: 10px;
  padding: 8px 12px;
  background-color: var(--primary);
  color: var(--on_primary);
  border: 1px solid var(--primary);
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.product button:hover {
  background-color: color-mix(in oklab, var(--primary) 90%, black 10%);
  border-color: color-mix(in oklab, var(--primary) 90%, black 10%);
}
.product:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px color-mix(in oklab, var(--color_text) 10%, transparent);
  transform: translateY(-1px);
}
.product button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .product {
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .product:hover {
    transform: none;
  }
}

/* ========== 🦶 Footer Section (brand-aware) ========== */
.store-footer {
  background-color: var(--footer_bg);
  color: var(--on_footer);
  padding: 0.75rem 2rem; /* reduced from 1.25rem to lower height by ~1/4 inch */
  border-top: 1px solid color-mix(in oklab, var(--footer_bg) 85%, black 15%);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.footer-container {
  width: 100%;
  display: flex;
  align-items: center; /* This also helps center children vertically */
  justify-content: space-between;
  flex-wrap: wrap;
}

.footer-left {
  text-align: left;
  align-items: center; /* This also helps center children vertically */
  color: var(--on_footer);
}

.footer-right {
  text-align: right;
}

.footer-right a {
  color: var(--on_footer);
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-left: 0.75rem;
  transition: color 0.2s, text-decoration-color 0.2s;
}

.footer-right a:hover {
  color: var(--accent);
}

.footer-right a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ========== 🌙 Minimal dark-mode polish (still var-driven) ========== */
html[data-theme="dark" i] .navbar a:hover {
  background: color-mix(
    in oklab,
    var(--navbar_bg, var(--color_surface)) 80%,
    var(--color_bg) 20%
  );
}

/* Ensure subtle header divider remains visible in dark */
html[data-theme="dark" i] .top-header-bar {
  border-bottom-color: color-mix(in oklab, var(--on_primary) 25%, transparent);
}

/* === Header search: map tokens to actual styles (beats header inheritance) === */
html[data-theme-id] .top-header-bar .header-search input[type="search"] {
  background-color: var(--search_bg, var(--field_surface, #fff)) !important;
  color: var(--on_search, var(--color_text, #0b1324)) !important;
  border: 1px solid
    var(--search_border, color-mix(in oklab, var(--primary) 30%, transparent)) !important;
  border-radius: 8px;
  padding: 8px 10px;
}

html[data-theme-id]
  .top-header-bar
  .header-search
  input[type="search"]::placeholder {
  /* Force strong contrast: bypass --search_placeholder (frozen by ETI) */
  color: var(--on_header, #ffffff) !important;
  opacity: 0.85; /* near-solid for readability over brand header */
}

html[data-theme-id] .top-header-bar .search-btn {
  background: transparent !important;
  color: var(--on_search, var(--color_text, #0b1324)) !important;
  border: 1px solid
    var(--search_border, color-mix(in oklab, var(--primary) 30%, transparent)) !important;
  border-radius: 8px;
  height: 36px;
  padding: 0 10px;
}
