/* ── Reset & Base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #f5f4f0;
  --bg2:        #eeece7;
  --bg3:        #e8e5df;
  --surface:    #ffffff;
  --surface2:   #f9f8f5;
  --border:     rgba(0,0,0,0.08);
  --border2:    rgba(0,0,0,0.13);
  --text:       #1a1714;
  --text2:      #5c574f;
  --text3:      #9c978d;
  --accent:     #b5892a;
  --accent2:    #d4a843;
  --accent-bg:  rgba(181,137,42,0.10);
  --radius:     10px;
  --radius-lg:  16px;
  --font-body:  'DM Sans', sans-serif;
  --font-disp:  'Playfair Display', serif;
  --font-deco:  'Cinzel', serif;
  --shadow:     0 8px 40px rgba(0,0,0,0.12);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Navbar ─────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2.5rem; height: 60px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 12px rgba(0,0,0,0.06);
}
.nav-brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { color: var(--accent); font-size: 16px; }
.brand-name { font-family: var(--font-deco); font-size: 18px; font-weight: 600; letter-spacing: 0.05em; color: var(--text); }
.nav-links { display: flex; gap: 2rem; }
.nav-links a { color: var(--text2); text-decoration: none; font-size: 14px; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: var(--accent); }

/* ── Hero ───────────────────────────────────────────── */
.hero {
  position: relative; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  gap: 4rem; padding: 80px 5% 40px; flex-wrap: wrap; overflow: hidden;
  background: linear-gradient(135deg, #fdfcf9 0%, #f0ede4 100%);
}
.hero-bg-pattern {
  position: absolute; inset: 0; z-index: 0;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(181,137,42,0.07) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(181,137,42,0.05) 0%, transparent 40%),
    repeating-linear-gradient(45deg, transparent, transparent 40px, rgba(0,0,0,0.012) 40px, rgba(0,0,0,0.012) 41px);
}
.hero-content { position: relative; z-index: 1; max-width: 540px; animation: fadeUp 0.7s ease both; }
.hero-visual   { position: relative; z-index: 1; flex-shrink: 0; animation: fadeUp 0.7s 0.15s ease both; }
#hero-canvas   { border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border2); max-width: 100%; }

.hero-eyebrow {
  font-size: 12px; font-weight: 500; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1.2rem; display: flex; align-items: center; gap: 8px;
}
.hero-eyebrow::before { content:''; width:32px; height:1px; background:var(--accent); }
.hero-title { font-family: var(--font-disp); font-size: clamp(2.4rem,5vw,3.8rem); font-weight: 700; line-height: 1.15; margin-bottom: 1.2rem; color: var(--text); }
.hero-title em { font-style: italic; color: var(--accent2); }
.hero-sub { font-size: 16px; color: var(--text2); line-height: 1.7; margin-bottom: 2rem; max-width: 420px; }
.hero-cta { display: flex; gap: 12px; margin-bottom: 2.5rem; flex-wrap: wrap; }
.hero-stats { display: flex; align-items: center; gap: 1.5rem; }
.stat { display: flex; flex-direction: column; }
.stat-num { font-family: var(--font-disp); font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-lbl  { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.stat-div  { width: 1px; height: 32px; background: var(--border2); }

/* ── Buttons ────────────────────────────────────────── */
.btn-primary {
  padding: 13px 28px; font-family: var(--font-body); font-size: 14px; font-weight: 600;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); cursor: pointer; transition: all 0.2s;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(181,137,42,0.25); }

.btn-ghost {
  padding: 13px 28px; font-family: var(--font-body); font-size: 14px; font-weight: 500;
  background: transparent; color: var(--text); border: 1.5px solid var(--border2);
  border-radius: var(--radius); cursor: pointer; transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

/* ── Section Base ───────────────────────────────────── */
.section { padding: 80px 5%; }
.section-header { text-align: center; margin-bottom: 3rem; }
.section-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.7rem; }
.section-title { font-family: var(--font-disp); font-size: clamp(1.8rem,3.5vw,2.8rem); font-weight: 700; margin-bottom: 0.6rem; color: var(--text); }
.section-sub { font-size: 15px; color: var(--text2); }

/* ── Filter Bar ─────────────────────────────────────── */
.filter-bar { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2.5rem; }
.filter-btn {
  padding: 7px 18px; font-size: 13px; font-weight: 500; font-family: var(--font-body);
  background: var(--surface); color: var(--text2); border: 1px solid var(--border2);
  border-radius: 999px; cursor: pointer; transition: all 0.18s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Template Grid ──────────────────────────────────── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 18px; }

.tmpl-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; cursor: pointer;
  transition: all 0.22s; position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.tmpl-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0,0,0,0.12); }
.tmpl-card.selected { border-color: var(--accent); border-width: 2px; }
.tmpl-canvas-wrap { background: #f0ebe0; padding: 8px; }
.tmpl-canvas-wrap canvas { display: block; width: 100%; height: auto; border-radius: 4px; }
.tmpl-info { padding: 12px 14px; }
.tmpl-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.tmpl-cat  { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--accent-bg); color: var(--accent); }
.tmpl-select-badge {
  position: absolute; top: 8px; right: 8px;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  opacity: 0; transition: opacity 0.2s;
}
.tmpl-card:hover .tmpl-select-badge,
.tmpl-card.selected .tmpl-select-badge { opacity: 1; }
.tmpl-card.selected .tmpl-select-badge::before { content: '✓ '; }

/* Field groups (shared) */
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group label { font-size: 11px; font-weight: 500; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; }
.label-hint { text-transform: none; letter-spacing: 0; color: var(--text3); font-style: italic; }
.field-group input, .field-group textarea, .field-group select {
  padding: 8px 10px; background: var(--bg3); color: var(--text);
  border: 1px solid var(--border2); border-radius: var(--radius);
  font-family: var(--font-body); font-size: 13px; outline: none; transition: border-color 0.18s;
}
.field-group input:focus, .field-group textarea:focus { border-color: var(--accent); }
.field-group textarea { resize: vertical; min-height: 64px; }

/* ── Editor Section ─────────────────────────────────── */
.editor-section { background: var(--bg2); border-top: 1px solid var(--border); }

.editor-layout { display: flex; gap: 24px; align-items: flex-start; }

.editor-panel {
  width: 300px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  position: sticky; top: 76px; max-height: calc(100vh - 90px); overflow-y: auto;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.editor-panel::-webkit-scrollbar { width: 4px; }
.editor-panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.panel-block { padding: 16px; border-bottom: 1px solid var(--border); }
.panel-block:last-child { border-bottom: none; }
.panel-block-title { font-size: 10px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text3); margin-bottom: 12px; }

.active-tmpl-badge {
  display: inline-block; padding: 6px 14px;
  background: var(--accent-bg); color: var(--accent);
  border: 1px solid rgba(181,137,42,0.3); border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
}

.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; transition: all 0.18s; position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.swatch:hover { transform: scale(1.12); }
.swatch.active::after {
  content:'✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Download buttons */
.btn-download {
  width: 100%; padding: 12px; font-family: var(--font-body); font-size: 14px; font-weight: 600;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); cursor: pointer; transition: all 0.2s; margin-bottom: 8px;
}
.btn-download:hover { background: var(--accent2); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(181,137,42,0.25); }

.btn-download-pdf {
  width: 100%; padding: 12px; font-family: var(--font-body); font-size: 14px; font-weight: 600;
  background: transparent; color: var(--accent); border: 1.5px solid var(--accent);
  border-radius: var(--radius); cursor: pointer; transition: all 0.2s; margin-bottom: 8px;
}
.btn-download-pdf:hover { background: var(--accent-bg); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(181,137,42,0.15); }

.download-note { font-size: 11px; color: var(--text3); text-align: center; }

/* Preview */
.preview-area { flex: 1; min-width: 0; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.preview-label { font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: 0.08em; text-transform: uppercase; }
.toolbar-right { display: flex; align-items: center; gap: 10px; }

.zoom-controls {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 4px 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.zoom-controls button { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; font-weight: 700; padding: 0 4px; transition: color 0.15s; }
.zoom-controls button:hover { color: var(--accent); }
#zoom-level { font-size: 12px; color: var(--text2); min-width: 36px; text-align: center; }

.canvas-wrapper {
  border-radius: var(--radius-lg); padding: 24px;
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center; overflow: auto;
  background: #c8c2b8;
  background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0.04) 1px, transparent 1px, transparent 12px);
}
#main-canvas {
  border-radius: 6px; box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  transform-origin: center; max-width: 100%; display: block;
}

/* ── Footer ─────────────────────────────────────────── */
.footer {
  text-align: center; padding: 3rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-brand { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 0.75rem; }
.footer-text { font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.footer-copy { font-size: 12px; color: var(--text3); }

/* ── Animations ─────────────────────────────────────── */
@keyframes fadeUp { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:translateY(0); } }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 900px) {
  .hero { flex-direction: column; text-align: center; padding-top: 90px; }
  .hero-eyebrow { justify-content: center; }
  .hero-cta, .hero-stats { justify-content: center; }
  .hero-sub { margin: 0 auto 2rem; }
  .editor-layout { flex-direction: column; }
  .editor-panel { width: 100%; position: static; max-height: none; }
  #hero-canvas { max-width: 380px; }
}
@media (max-width: 600px) {
  .navbar { padding: 0 1.2rem; }
  .nav-links { gap: 1rem; }
  .section { padding: 60px 4%; }
  .template-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
}
@media (max-width: 420px) {
  .template-grid { grid-template-columns: 1fr; }
}
