/*
 * Stan's Cigars — design system.
 *
 * Theme: "Charcoal & Cognac" — a moody, editorial dark palette with a single
 * warm cognac accent, built so the cigar photography is the focus. Light,
 * paper-toned surfaces are reserved for forms and back-office tables where
 * legibility matters most.
 *
 * Organised as:
 *   1. Design tokens (:root)
 *   2. Base / reset
 *   3. Layout primitives
 *   4. Header & navigation
 *   5. Hero
 *   6. Buttons
 *   7. Product cards & catalog grid
 *   8. Product detail
 *   9. Generic cards, stats, tables
 *  10. Forms
 *  11. Badges, flashes, misc
 *  12. Footer
 *  13. Admin overrides
 */

/* ------------------------------------------------------------------ *
 * 1. Design tokens
 * ------------------------------------------------------------------ */
:root {
  /* Surfaces — charcoal to graphite */
  --bg:          #16181a;
  --bg-elevated: #1b1e20;
  --surface:     #1f2225;
  --surface-2:   #24282b;
  --surface-3:   #2c3034;

  /* Light "paper" surfaces (forms, admin tables) */
  --paper:       #eef0f2;
  --paper-2:     #e3e6e9;
  --ink:         #1a1c1e;

  /* Text on dark */
  --text:        #e8eaec;
  --text-soft:   #c2c6ca;
  --muted:       #8b9097;
  --muted-dark:  #5f6469;

  /* Accent — cognac / burnt amber */
  --accent:      #b4633a;
  --accent-hover:#c8794d;
  --accent-deep: #93482a;
  --accent-tint: rgba(180, 99, 58, 0.14);

  /* Status hues, tuned for the dark ground */
  --good:        #6fbf8b;
  --good-bg:     rgba(111, 191, 139, 0.14);
  --warn:        #e0b15a;
  --warn-bg:     rgba(224, 177, 90, 0.14);
  --bad:         #d97a72;
  --bad-bg:      rgba(217, 122, 114, 0.14);

  /* Lines & shadows */
  --line:        rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --shadow:      0 10px 30px -12px rgba(0, 0, 0, 0.7);
  --shadow-lg:   0 24px 60px -24px rgba(0, 0, 0, 0.85);

  /* Shape */
  --radius:      14px;
  --radius-sm:   9px;
  --radius-pill: 999px;

  /* Type */
  --font-display: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype",
                  Palatino, Georgia, "Times New Roman", serif;
  --font-sans:    "Inter", system-ui, -apple-system, BlinkMacSystemFont,
                  "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Rhythm */
  --space:       1rem;
  --maxw:        1140px;
}

/* ------------------------------------------------------------------ *
 * 2. Base / reset
 * ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #20242a 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.6;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: 0.2px;
  margin: 0 0 0.5rem;
}
h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem); }
h3 { font-size: 1.35rem; }

p { margin: 0 0 1rem; }

a { color: var(--accent-hover); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--accent); text-decoration: none; }

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

::selection { background: var(--accent); color: #fff; }

/* A reusable "eyebrow" — small uppercase tracked label */
.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-hover);
}

/* ------------------------------------------------------------------ *
 * 3. Layout primitives
 * ------------------------------------------------------------------ */
.container { width: min(var(--maxw), 92%); margin: 0 auto; }

main.container { padding: 2.25rem 0 4rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.75rem;
  padding-bottom: 1.1rem; border-bottom: 1px solid var(--line);
}
.page-head h1 { margin: 0; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ *
 * 4. Header & navigation
 * ------------------------------------------------------------------ */
.site-header {
  background: rgba(18, 20, 22, 0.72);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0.9rem 0;
  position: sticky; top: 0; z-index: 50;
}
.nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.brand {
  font-family: var(--font-display);
  color: var(--text);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: 0.3px;
  display: inline-flex; align-items: baseline; gap: 0.5rem;
}
.brand::before {
  content: "";
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
  align-self: center;
}
.brand:hover { color: var(--text); }

.nav-links { display: flex; align-items: center; gap: 1.35rem; flex-wrap: wrap; }
.nav-links a {
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.nav-links a:hover { color: var(--text); }
.nav-links .admin-link { color: var(--accent-hover); }
.nav-links .admin-link:hover { color: var(--accent); }

/* ------------------------------------------------------------------ *
 * 5. Hero
 * ------------------------------------------------------------------ */
.hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(105deg, rgba(15,16,18,0.92) 0%, rgba(15,16,18,0.55) 55%, rgba(15,16,18,0.2) 100%),
    radial-gradient(900px 500px at 85% 20%, #3a2a20 0%, transparent 60%),
    var(--surface);
  padding: clamp(2rem, 1.2rem + 4vw, 4rem);
  margin-bottom: 2.25rem;
  box-shadow: var(--shadow);
}
.hero h1 { max-width: 16ch; margin: 0.5rem 0 0.75rem; }
.hero p { color: var(--text-soft); max-width: 56ch; font-size: 1.05rem; }
.hero .actions { margin-top: 1.5rem; }

/* ------------------------------------------------------------------ *
 * 6. Buttons
 * ------------------------------------------------------------------ */
.button, button, input[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: 0.6rem 1.1rem; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font-sans); font-size: 0.92rem; font-weight: 600;
  letter-spacing: 0.01em; line-height: 1.2;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.button:hover, button:hover, input[type="submit"]:hover {
  background: var(--accent-hover); color: #fff; box-shadow: 0 8px 20px -10px var(--accent);
}
.button:active, button:active { transform: translateY(1px); }

.button.small, button.small { padding: 0.38rem 0.75rem; font-size: 0.82rem; }
.button.secondary, button.secondary {
  background: transparent; color: var(--text-soft);
  border-color: var(--line-strong);
}
.button.secondary:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }
.button.danger, button.danger { background: #8e3a36; }
.button.danger:hover { background: #a4453f; box-shadow: none; }

.linklike {
  background: none; color: var(--text-soft); padding: 0; border: 0; cursor: pointer;
  font: inherit; font-weight: 500;
}
.linklike:hover { color: var(--text); text-decoration: underline; }

/* ------------------------------------------------------------------ *
 * 7. Product cards & catalog grid
 * ------------------------------------------------------------------ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.5rem;
}

.product-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.product-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lg);
}

/* The image is the hero of every card */
.product-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-elevated);
}
.product-media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.4s ease;
}
.product-card:hover .product-media img { transform: scale(1.05); }

/* Elegant placeholder when no photo has been uploaded */
.product-media.is-placeholder {
  display: grid; place-items: center;
  background:
    radial-gradient(120% 120% at 30% 20%, #2b2017 0%, transparent 55%),
    linear-gradient(160deg, #23262a, #16181a);
}
.product-media .monogram {
  font-family: var(--font-display);
  font-size: 3.4rem; font-weight: 600;
  color: var(--accent);
  width: 5.5rem; height: 5.5rem; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--accent-deep);
  background: rgba(180, 99, 58, 0.08);
  letter-spacing: 0.02em;
}
.product-media .placeholder-note {
  position: absolute; bottom: 0.75rem; left: 0; right: 0;
  text-align: center; font-size: 0.72rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted-dark);
}

.product-body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.product-body .brand-line {
  font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent-hover); font-weight: 600;
}
.product-body h3 { margin: 0; font-size: 1.3rem; }
.product-body h3 a { color: var(--text); }
.product-body h3 a:hover { color: var(--accent-hover); }
.product-specs { color: var(--muted); font-size: 0.86rem; margin: 0; }

.product-foot { margin-top: auto; padding-top: 0.6rem; }
.product-foot .actions { margin-top: 0.6rem; }

.price {
  font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 600; color: var(--text);
  line-height: 1;
}
.price .unit { font-family: var(--font-sans); font-size: 0.8rem; color: var(--muted); font-weight: 400; }

.signin-hint { color: var(--muted); font-size: 0.9rem; font-style: italic; }

/* ------------------------------------------------------------------ *
 * 8. Product detail
 * ------------------------------------------------------------------ */
.product-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: start;
}
.product-detail .detail-media {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}
.product-detail .detail-media img { width: 100%; height: 100%; object-fit: cover; }
.product-detail .detail-media.is-placeholder { display: grid; place-items: center;
  background: radial-gradient(120% 120% at 30% 20%, #2b2017 0%, transparent 55%), linear-gradient(160deg, #23262a, #16181a); }
.product-detail .detail-media .monogram { font-size: 5rem; width: 8rem; height: 8rem; }

.product-info h1 { margin-bottom: 0.35rem; }
.product-info .product-specs { font-size: 0.95rem; margin-bottom: 1.25rem; }
.product-info .description { color: var(--text-soft); border-top: 1px solid var(--line); padding-top: 1.25rem; margin-top: 1.25rem; }
.product-info .price { font-size: 2.4rem; }
.product-info .buy-box {
  margin-top: 1.5rem; padding: 1.4rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
.back-link { display: inline-block; margin-bottom: 1.25rem; color: var(--muted); font-size: 0.9rem; }
.back-link:hover { color: var(--text); }

@media (max-width: 760px) {
  .product-detail { grid-template-columns: 1fr; gap: 1.5rem; }
}

/* ------------------------------------------------------------------ *
 * 9. Generic cards, stats, tables
 * ------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 0.35rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem 1.35rem;
}
.stat .label { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.stat .num { font-family: var(--font-display); font-size: 2.1rem; font-weight: 600; color: var(--text); }

table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); }
th {
  background: var(--surface-2); font-size: 0.74rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); font-weight: 600;
}
td { color: var(--text-soft); }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

.totals { text-align: right; font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; margin-top: 1rem; color: var(--text); }

/* ------------------------------------------------------------------ *
 * 10. Forms
 * ------------------------------------------------------------------ */
form .field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.85rem; color: var(--text-soft); letter-spacing: 0.01em; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="tel"], input[type="search"], textarea, select {
  width: 100%; padding: 0.62rem 0.7rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  font-family: var(--font-sans); font-size: 1rem;
  background: var(--bg-elevated); color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
input::placeholder, textarea::placeholder { color: var(--muted-dark); }
textarea { min-height: 5.5rem; resize: vertical; }
select { appearance: none; }

input[type="file"] { color: var(--text-soft); font-size: 0.9rem; }
input[type="file"]::file-selector-button {
  margin-right: 0.8rem; padding: 0.45rem 0.8rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 600;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); margin-right: 0.4rem; }
label:has(> input[type="checkbox"]) { display: inline-flex; align-items: center; font-weight: 500; }

.form-narrow { max-width: 540px; }

.image-preview { margin-bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.image-preview img {
  width: 220px; height: 220px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
}

.errors {
  background: var(--bad-bg); border: 1px solid rgba(217,122,114,0.4); color: var(--bad);
  padding: 0.85rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem;
}
.errors ul { margin: 0.25rem 0 0 1.1rem; }

/* ------------------------------------------------------------------ *
 * 11. Badges, flashes, misc
 * ------------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.22rem 0.7rem; border-radius: var(--radius-pill);
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 0.42rem; height: 0.42rem; border-radius: 50%; background: currentColor; }
.badge.pending   { background: var(--warn-bg); color: var(--warn); border-color: rgba(224,177,90,0.3); }
.badge.confirmed { background: var(--good-bg); color: var(--good); border-color: rgba(111,191,139,0.3); }
.badge.cancelled { background: var(--bad-bg);  color: var(--bad);  border-color: rgba(217,122,114,0.3); }
.badge.in  { background: var(--good-bg); color: var(--good); border-color: rgba(111,191,139,0.3); }
.badge.out { background: var(--bad-bg);  color: var(--bad);  border-color: rgba(217,122,114,0.3); }

.flash {
  padding: 0.85rem 1.1rem; border-radius: var(--radius-sm); margin-bottom: 1.5rem;
  border: 1px solid transparent; font-weight: 500;
}
.flash-notice { background: var(--good-bg); color: var(--good); border-color: rgba(111,191,139,0.3); }
.flash-alert  { background: var(--bad-bg);  color: var(--bad);  border-color: rgba(217,122,114,0.3); }

.notice-box {
  background: var(--surface); color: var(--text-soft);
  padding: 0.7rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); display: inline-block; font-size: 0.92rem;
}

/* ------------------------------------------------------------------ *
 * 12. Footer
 * ------------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 2rem 0; margin-top: 2rem;
  color: var(--muted); font-size: 0.9rem;
  background: rgba(0,0,0,0.2);
}

/* ------------------------------------------------------------------ *
 * 12b. Site lock screen (gate)
 * ------------------------------------------------------------------ */
.gate-screen {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 2rem 1.25rem;
}
.gate-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.75rem, 1.2rem + 2.5vw, 2.75rem);
  text-align: left;
}
.gate-brand { font-size: 1.4rem; display: inline-flex; margin-bottom: 1.5rem; }
.gate-card h1 { margin: 0.5rem 0 0.4rem; }
.gate-card .eyebrow { display: block; }
.gate-card p { color: var(--text-soft); }
.gate-form { margin-top: 1.5rem; }
.gate-form .button, .gate-form input[type="submit"] { width: 100%; margin-top: 0.4rem; padding: 0.7rem; }

/* ------------------------------------------------------------------ *
 * 13. Admin overrides — lean on a flatter, utilitarian feel
 * ------------------------------------------------------------------ */
.admin-header { background: rgba(28, 22, 18, 0.8); border-bottom-color: rgba(180,99,58,0.35); }
.admin-header .brand::before { background: var(--accent-hover); }
body.admin { background: var(--bg); }
