/* ==================================================================
   STYLES — "Moody West Coast Timber Guild": dark, warm, lantern-lit.
   Deliberately distinct from both the main Acuity site (navy/copper/
   Playfair) and the Auto Estimator demo (cool cyan/near-black/Rajdhani)
   — warmer and earthier than either. Layout (spacing/grid/flex/
   breakpoints) is handled by Tailwind utility classes in index.html.
   Everything here is either global dark-theme chrome or a component
   whose color comes from the --accent custom property (set at runtime
   from js/config.js), so re-skinning never requires touching this file.
   ================================================================== */

:root {
  --accent: #d98a2f;
  --accent-rgb: 217, 138, 47;
  --accent-contrast: #1f1206;
  --coal: #16110c;
  --panel: #221b13;
  --panel2: #2a2118;
  --edge: #3a2f22;
  --edge2: #5c4a34;
  --ink: #e6dac4;
  --forest: #3c5c46;
  --stone: #8a8478;
  --metal: #c7c9d0;
  --metal-shade: #54565e;

  /* Painted finishes only — grain species swatches use a real photo
     background-image instead (set inline in main.js), not a flat color. */
  --swatch-classic_white: #f2ede1;
  --swatch-forest_green: #33513f;
}

html { scroll-behavior: smooth; }

body {
  background-color: var(--coal);
  color: var(--ink);
  font-family: 'Work Sans', sans-serif;
  position: relative;
}

.font-display { font-family: 'Fraunces', serif; }

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

a { color: inherit; }

/* ---- Full-page grain overlay: tactile "workshop" atmosphere ---- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='60' viewBox='0 0 120 60'%3E%3Cg stroke='%23000' stroke-width='1' fill='none' opacity='0.5'%3E%3Cpath d='M0 10 Q30 5 60 12 T120 8'/%3E%3Cpath d='M0 28 Q30 34 60 26 T120 30'/%3E%3Cpath d='M0 46 Q30 40 60 48 T120 44'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---- Header ---- */
#site-header {
  border-bottom: 1px solid transparent;
  transition: all 0.3s ease;
}
#site-header.is-scrolled {
  background-color: rgba(22, 17, 12, 0.85);
  backdrop-filter: blur(16px);
  border-bottom-color: var(--edge);
}
.nav-link { color: var(--ink); opacity: 0.75; transition: opacity 0.2s ease, color 0.2s ease; }
.nav-link:hover, .nav-link.active { opacity: 1; color: var(--accent); }

.btn-accent {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--accent); color: var(--accent-contrast);
  font-weight: 700; letter-spacing: 0.02em;
  border-radius: 0.4rem;
  transition: box-shadow 0.25s ease, transform 0.2s ease;
}
.btn-accent:hover { box-shadow: 0 0 30px -4px rgba(var(--accent-rgb), 0.55); transform: translateY(-1px); }

.btn-outline {
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--edge); color: var(--ink);
  font-weight: 700; border-radius: 0.4rem;
  transition: border-color 0.2s ease;
}
.btn-outline:hover { border-color: rgba(var(--accent-rgb), 0.6); }

/* ---- Hero ---- */
.hero-backdrop {
  background-image: linear-gradient(180deg, rgba(22,17,12,0.55) 0%, rgba(22,17,12,0.88) 65%, var(--coal) 100%), var(--hero-photo, url('../assets/images/coastal-shoreline.jpg'));
  background-size: cover;
  background-position: center 60%;
  background-attachment: fixed;
}
@media (max-width: 768px) {
  .hero-backdrop { background-attachment: scroll; }
}

.text-gradient-accent {
  background: linear-gradient(90deg, #f6ecd8 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@keyframes lantern-flicker {
  0%, 100% { opacity: 0.55; }
  8% { opacity: 0.7; }
  22% { opacity: 0.5; }
  40% { opacity: 0.65; }
  63% { opacity: 0.52; }
  81% { opacity: 0.68; }
}
.animate-lantern { animation: lantern-flicker 5s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  .animate-lantern { animation: none; }
}

.demo-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--edge);
  background: rgba(34, 27, 19, 0.7);
  backdrop-filter: blur(6px);
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em;
  color: var(--ink);
}
.demo-badge .dot { width: 6px; height: 6px; border-radius: 9999px; background: var(--accent); }

/* ---- Section divider: driftwood photo band + plank-line motif ---- */
.plank-divider {
  position: relative;
  height: 130px;
  background-image:
    linear-gradient(180deg, var(--coal) 0%, rgba(22,17,12,0.55) 25%, rgba(22,17,12,0.55) 75%, var(--coal) 100%),
    url('../assets/images/coastal-driftwood.jpg');
  background-size: cover;
  background-position: center 40%;
}
.plank-divider::after {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(0,0,0,0.35) 0, rgba(0,0,0,0.35) 1px, transparent 1px, transparent 64px);
}

/* ---- Carved-edge panel: dual drop-shadow instead of a crisp border ---- */
.carved-panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 0.9rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 235, 205, 0.05),
    0 18px 40px -20px rgba(0, 0, 0, 0.65);
}

/* ---- Piece type cards ---- */
.piece-card {
  position: relative;
  text-align: left;
  background: var(--panel); border: 1px solid var(--edge);
  border-radius: 0.75rem; padding: 1.1rem;
  cursor: pointer; transition: border-color 0.25s ease, transform 0.2s ease, background 0.25s ease;
}
.piece-card:hover { border-color: rgba(var(--accent-rgb), 0.45); transform: translateY(-2px); }
.piece-card.active { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.08); box-shadow: 0 0 24px -8px rgba(var(--accent-rgb), 0.4); }
.piece-card-icon {
  width: 2.5rem; height: 2.5rem; border-radius: 0.5rem;
  background: rgba(var(--accent-rgb), 0.12); border: 1px solid rgba(var(--accent-rgb), 0.3);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 1rem; margin-bottom: 0.75rem;
}
.piece-card-label { display: block; font-family: 'Fraunces', serif; font-weight: 600; font-size: 1rem; color: var(--ink); }
.piece-card-desc { display: block; font-size: 0.78rem; color: rgba(230, 218, 196, 0.55); margin-top: 0.3rem; line-height: 1.4; }

/* ---- Species swatches ---- */
.swatch {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  background: none; border: none; cursor: pointer; padding: 0.4rem;
  border-radius: 0.6rem; transition: background 0.2s ease;
}
.swatch:hover { background: rgba(var(--accent-rgb), 0.08); }
.swatch-color {
  width: 2.75rem; height: 2.75rem; border-radius: 9999px;
  border: 2px solid var(--edge); display: block;
  background-size: cover; background-position: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.swatch.active .swatch-color { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(var(--accent-rgb), 0.25); }
.swatch-label { font-size: 0.7rem; color: rgba(230, 218, 196, 0.7); text-align: center; line-height: 1.2; }

/* ---- Generic single-select pills (edge / base / scale) ---- */
.pill {
  background: var(--panel2); border: 1px solid var(--edge); color: var(--ink);
  font-size: 0.85rem; font-weight: 600;
  padding: 0.55rem 1rem; border-radius: 9999px; cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.pill:hover { border-color: rgba(var(--accent-rgb), 0.45); }
.pill.active { background: rgba(var(--accent-rgb), 0.14); border-color: var(--accent); color: var(--accent); }

/* ---- Live preview frame ---- */
.preview-frame {
  position: relative;
  background: linear-gradient(160deg, var(--panel2), var(--coal));
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 0.9rem;
  box-shadow: 0 0 55px -12px rgba(var(--accent-rgb), 0.35);
  overflow: hidden;
}
.preview-frame::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 40px -6px rgba(var(--accent-rgb), 0.4);
  pointer-events: none;
}
#piece-preview-svg { width: 100%; height: auto; display: block; }

/* ---- Live preview motion: every interaction (piece/edge/base/species
   swap) visibly animates, echoing Auto Estimator's gauge-needle easing
   so both demos share a signature "spring settle" feel. ---- */
.wood-surface { transition: opacity 0.18s ease-out; }
.wood-surface.species-swap { opacity: 0.35; }

.contact-shadow-group,
.base-overlay-group,
.wood-surface-group,
.edge-overlay-group {
  transform-box: fill-box;
  transform-origin: center;
}

@keyframes settle-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.contact-shadow-group.piece-enter { animation: settle-in 0.5s cubic-bezier(0.22, 0.9, 0.24, 1) both; }
.piece-group.piece-enter .base-overlay-group { animation: settle-in 0.45s cubic-bezier(0.22, 0.9, 0.24, 1) both; }
.piece-group.piece-enter .wood-surface-group { animation: settle-in 0.45s cubic-bezier(0.22, 0.9, 0.24, 1) 70ms both; }
.piece-group.piece-enter .edge-overlay-group { animation: settle-in 0.45s cubic-bezier(0.22, 0.9, 0.24, 1) 140ms both; }

@keyframes pop-in {
  0% { opacity: 0; transform: scale(0.92); }
  60% { opacity: 1; transform: scale(1.015); }
  100% { opacity: 1; transform: scale(1); }
}
.base-overlay-group.pop-in,
.edge-overlay-group.pop-in { animation: pop-in 0.32s cubic-bezier(0.22, 0.9, 0.24, 1); }

/* ---- Price panel ---- */
.price-panel {
  background: linear-gradient(135deg, var(--panel2), var(--coal));
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 0.75rem;
  box-shadow: 0 0 55px -10px rgba(var(--accent-rgb), 0.3);
}

/* ---- Form fields ---- */
.field-input {
  width: 100%; background: var(--panel2); border: 1px solid var(--edge);
  border-radius: 0.5rem; padding: 0.75rem; font-size: 0.875rem; color: var(--ink);
  color-scheme: dark;
}
.field-input:focus {
  outline: none; border-color: rgba(var(--accent-rgb), 0.6);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.4);
}

/* Honeypot field — hidden from humans, visible to bots */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- Preset switcher (hero) ---- */
.preset-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--panel); border: 1px solid var(--edge); color: var(--ink);
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 0.85rem;
  padding: 0.5rem 1rem; border-radius: 9999px; cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.preset-pill:hover { border-color: rgba(var(--accent-rgb), 0.5); }
.preset-pill.active {
  background: rgba(var(--accent-rgb), 0.14); border-color: var(--accent); color: var(--accent);
}
.preset-pill.active .preset-pill-dot { background: var(--accent); }
.preset-pill-dot { width: 6px; height: 6px; border-radius: 9999px; background: var(--edge2); }

/* ---- Trust icons ---- */
.trust-icon {
  width: 4rem; height: 4rem; border-radius: 9999px;
  background: var(--panel2); border: 1px solid rgba(var(--accent-rgb), 0.3);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 1.5rem;
  box-shadow: 0 0 25px -5px rgba(var(--accent-rgb), 0.45);
  margin: 0 auto 1.25rem;
}

/* ---- Admin panel (example) ---- */
.admin-toggle {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 95;
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--edge);
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 0.9rem;
  padding: 0.7rem 1.1rem; border-radius: 9999px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.admin-toggle:hover { border-color: rgba(var(--accent-rgb), 0.6); transform: translateY(-2px); }
.admin-toggle i { color: var(--accent); }

.admin-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 96;
}
.admin-overlay.hidden { display: none; }

.admin-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 97;
  width: min(480px, 100vw);
  background: var(--panel); border-left: 1px solid var(--edge);
  display: flex; flex-direction: column;
  box-shadow: -10px 0 40px rgba(0,0,0,0.5);
}
.admin-panel.hidden { display: none; }

.admin-panel-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.5rem 1.5rem 1rem; border-bottom: 1px solid var(--edge);
}
.admin-panel-header h3 {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 1.2rem; color: var(--ink);
  display: flex; align-items: center; gap: 0.6rem;
}
.admin-example-tag {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.06em;
  color: var(--accent-contrast); background: var(--accent);
  padding: 0.15rem 0.45rem; border-radius: 0.25rem;
}
.admin-close-btn {
  background: none; border: 1px solid var(--edge); color: var(--ink);
  width: 2rem; height: 2rem; border-radius: 0.4rem; cursor: pointer; flex-shrink: 0;
}
.admin-close-btn:hover { border-color: rgba(var(--accent-rgb), 0.6); }

.admin-panel-body { flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem; }

.admin-section { margin-bottom: 1.75rem; }
.admin-section h4 {
  font-family: 'Fraunces', serif; font-weight: 600; font-size: 1rem; color: var(--ink);
}
.admin-hint { font-size: 0.75rem; color: rgba(230, 218, 196, 0.55); margin-top: 0.25rem; line-height: 1.5; }

.admin-table { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; }
.admin-row {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--panel2); border: 1px solid var(--edge); border-radius: 0.4rem;
  padding: 0.5rem 0.6rem; margin-top: 0.4rem;
}
.admin-row-label { flex: 1; font-size: 0.8rem; color: var(--ink); }

.admin-input {
  width: 5.5rem; background: var(--coal); border: 1px solid var(--edge); border-radius: 0.3rem;
  color: var(--ink); font-size: 0.85rem; padding: 0.35rem 0.5rem; color-scheme: dark;
}
.admin-input:focus { outline: none; border-color: rgba(var(--accent-rgb), 0.6); }

.admin-panel-footer { border-top: 1px solid var(--edge); padding: 1rem 1.5rem 1.25rem; }
.admin-reset-btn {
  width: 100%; background: none; border: 1px solid var(--edge); color: var(--ink);
  font-family: 'Fraunces', serif; font-weight: 600; padding: 0.6rem; border-radius: 0.4rem; cursor: pointer;
}
.admin-reset-btn:hover { border-color: rgba(var(--accent-rgb), 0.6); }
