/* ================================================================
   SVG PATTERN GENERATOR — style.css
   ================================================================ */

/* ── Google Font ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
  /* Palette — Light Theme */
  --bg-app:         #f0f2f7;
  --bg-sidebar:     #ffffff;
  --bg-section:     #f5f6fa;
  --bg-input:       #eef0f6;
  --bg-thumb:       #e8eaf2;
  --border:         #e0e2ec;
  --border-hover:   #b8bcce;

  --text-primary:   #1a1b2e;
  --text-secondary: #4a4d6a;
  --text-muted:     #8a8da8;

  --accent:         #0084ff;
  --accent-light:   #339dff;
  --accent-glow:    rgba(0, 132, 255, 0.18);
  --accent-hover:   #006ece;

  --success:        #059669;
  --success-bg:     rgba(5, 150, 105, 0.12);

  /* Layout */
  --sidebar-w:      320px;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;

  /* Typography */
  --font:           'Inter', system-ui, sans-serif;

  /* Transitions */
  --t-fast:         120ms ease;
  --t-smooth:       250ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-bounce:       350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  display: flex;
  height: 100svh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 99px; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100svh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--t-smooth);
}

/* ── Brand ───────────────────────────────────────────────── */
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-glow), rgba(99,102,241,0.05));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

/* ── Sections ────────────────────────────────────────────── */
.sidebar__section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Pattern section scrollable */
.sidebar__section--patterns {
  display: flex;
  flex-direction: column;
  /* Allow the section to grow and scroll */
  min-height: 0;
  flex-shrink: 1;
  overflow: hidden;
  padding-bottom: 12px;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.section-label__icon {
  font-size: 0.8rem;
  color: var(--accent-light);
}

.pattern-count-badge {
  margin-left: auto;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(79, 70, 229, 0.25);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  letter-spacing: 0.2px;
}

/* ================================================================
   PATTERN GRID
   ================================================================ */
.pattern-grid-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 260px;
  padding-right: 4px;
  margin-right: -4px;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

.pattern-grid-scroll::-webkit-scrollbar { width: 4px; }
.pattern-grid-scroll::-webkit-scrollbar-track { background: transparent; }
.pattern-grid-scroll::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 99px;
}
.pattern-grid-scroll::-webkit-scrollbar-thumb:hover { background: var(--accent-light); }

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pattern-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color var(--t-fast), transform var(--t-bounce), box-shadow var(--t-fast);
  background-color: #f8f9ff;
  outline: none;
}

.pattern-thumb:hover {
  border-color: var(--accent-light);
  transform: scale(1.07);
  box-shadow: 0 0 0 3px var(--accent-glow);
  z-index: 2;
}

.pattern-thumb:focus-visible {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.pattern-thumb.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), inset 0 0 0 1px var(--accent);
}

.pattern-thumb .thumb-inner {
  width: 100%;
  height: 100%;
  background-size: auto;
  background-repeat: repeat;
}

.pattern-thumb .thumb-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 4px 2px;
  opacity: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  transition: opacity var(--t-fast);
  font-size: 0.5rem;
  font-weight: 600;
  color: #fff;
  text-align: center;
  pointer-events: none;
}

.pattern-thumb:hover .thumb-label,
.pattern-thumb.is-active .thumb-label {
  opacity: 1;
}

/* ================================================================
   COLOR CONTROLS
   ================================================================ */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.control-row + .control-row {
  border-top: 1px solid var(--border);
}

.control-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.color-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  border: 2px solid var(--border-hover);
  border-radius: var(--radius-sm);
  padding: 3px;
  background: var(--bg-input);
  cursor: pointer;
  transition: border-color var(--t-fast), transform var(--t-bounce);
}

input[type="color"]:hover { border-color: var(--accent-light); transform: scale(1.05); }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; border-radius: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }

.color-hex-display {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  min-width: 76px;
  text-align: center;
  transition: color var(--t-fast);
}

/* ================================================================
   RANGE SLIDER
   ================================================================ */
.slider-wrap { display: flex; flex-direction: column; gap: 10px; }

.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.slider-label-min, .slider-label-max { font-size: 0.65rem; }

.slider-value {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(79, 70, 229, 0.25);
  padding: 2px 10px;
  border-radius: 99px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) calc(var(--val, 30%) * 1%),
    var(--border-hover) calc(var(--val, 30%) * 1%),
    var(--border-hover) 100%
  );
  border-radius: 99px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15), 0 0 0 3px var(--accent-glow);
  transition: transform var(--t-bounce), box-shadow var(--t-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2), 0 0 0 5px var(--accent-glow);
}

input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15), 0 0 0 3px var(--accent-glow);
}

/* ================================================================
   CSS OUTPUT
   ================================================================ */
.output-area-wrap {
  position: relative;
  margin-bottom: 12px;
}

.css-output {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.65rem;
  line-height: 1.6;
  padding: 10px 12px;
  resize: none;
  outline: none;
  transition: border-color var(--t-fast);
}

.css-output:focus { border-color: var(--accent-light); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-bounce), box-shadow var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
  outline: none;
}

.btn:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn--primary:active { transform: translateY(0); }

.btn--primary.copied {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn--secondary {
  background: var(--bg-section);
  color: var(--text-secondary);
  border-color: var(--border-hover);
}

.btn--secondary:hover {
  background: var(--bg-thumb);
  color: var(--text-primary);
  border-color: var(--accent-light);
  transform: translateY(-1px);
}

.btn--secondary:active { transform: translateY(0); }

/* ── Sidebar Footer ───────────────────────────────────────── */
.sidebar__footer {
  margin-top: auto;
  padding: 16px 20px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ================================================================
   PREVIEW AREA
   ================================================================ */
.preview-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #f0f2f7;
  transition: background-color var(--t-smooth);
}

.preview-overlay {
  position: absolute;
  inset: 0;
  background-image: none;
  background-repeat: repeat;
  transition: background-image var(--t-smooth), opacity var(--t-smooth);
  will-change: background-image;
}

/* ── Info Card ───────────────────────────────────────────── */
.preview-info-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: var(--radius-lg);
  padding: 28px 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  transition: opacity var(--t-smooth);
  box-shadow: 0 8px 40px rgba(79,70,229,0.12), 0 1px 3px rgba(0,0,0,0.08);
}

.preview-info-card__icon {
  color: var(--accent-light);
  margin-bottom: 4px;
}

.preview-info-card__name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.preview-info-card__hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ================================================================
   TOAST
   ================================================================ */
.toast {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
  white-space: nowrap;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  z-index: 500;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--success); color: var(--success); }

/* ================================================================
   SIDEBAR TOGGLE (mobile)
   ================================================================ */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 0;
  transition: background var(--t-fast);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.sidebar-toggle:hover { background: var(--bg-section); }

.sidebar-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 99px;
  transition: transform var(--t-smooth), opacity var(--t-fast);
}

.sidebar-toggle[aria-expanded="true"] .sidebar-toggle__bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle__bar:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle__bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  body { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100svh;
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 90vw);
    z-index: 150;
  }

  .sidebar.is-open { transform: translateX(0); }

  .sidebar-toggle { display: flex; }

  .preview-area { width: 100%; }
}

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

.pattern-thumb {
  animation: fadeInUp 0.3s ease both;
}

/* Stagger delay — capped so late items don't wait forever */
.pattern-thumb:nth-child(1)  { animation-delay: 0.01s; }
.pattern-thumb:nth-child(2)  { animation-delay: 0.03s; }
.pattern-thumb:nth-child(3)  { animation-delay: 0.05s; }
.pattern-thumb:nth-child(4)  { animation-delay: 0.07s; }
.pattern-thumb:nth-child(5)  { animation-delay: 0.09s; }
.pattern-thumb:nth-child(6)  { animation-delay: 0.11s; }
.pattern-thumb:nth-child(7)  { animation-delay: 0.13s; }
.pattern-thumb:nth-child(8)  { animation-delay: 0.15s; }
.pattern-thumb:nth-child(9)  { animation-delay: 0.17s; }
.pattern-thumb:nth-child(10) { animation-delay: 0.19s; }
.pattern-thumb:nth-child(11) { animation-delay: 0.21s; }
.pattern-thumb:nth-child(12) { animation-delay: 0.23s; }
.pattern-thumb:nth-child(13) { animation-delay: 0.25s; }
.pattern-thumb:nth-child(14) { animation-delay: 0.27s; }
.pattern-thumb:nth-child(15) { animation-delay: 0.29s; }
.pattern-thumb:nth-child(16) { animation-delay: 0.31s; }
.pattern-thumb:nth-child(17) { animation-delay: 0.33s; }
.pattern-thumb:nth-child(18) { animation-delay: 0.35s; }
.pattern-thumb:nth-child(19) { animation-delay: 0.37s; }
.pattern-thumb:nth-child(20) { animation-delay: 0.39s; }
.pattern-thumb:nth-child(21) { animation-delay: 0.40s; }
.pattern-thumb:nth-child(22) { animation-delay: 0.40s; }
.pattern-thumb:nth-child(23) { animation-delay: 0.41s; }
.pattern-thumb:nth-child(24) { animation-delay: 0.41s; }
.pattern-thumb:nth-child(25) { animation-delay: 0.42s; }
.pattern-thumb:nth-child(26) { animation-delay: 0.42s; }
.pattern-thumb:nth-child(27) { animation-delay: 0.43s; }
.pattern-thumb:nth-child(28) { animation-delay: 0.43s; }
.pattern-thumb:nth-child(29) { animation-delay: 0.44s; }
.pattern-thumb:nth-child(30) { animation-delay: 0.44s; }
.pattern-thumb:nth-child(31) { animation-delay: 0.45s; }
.pattern-thumb:nth-child(32) { animation-delay: 0.45s; }
.pattern-thumb:nth-child(n+33) { animation-delay: 0.46s; }

/* ── Outline Button ───────────────────────────────────────── */
.btn--outline {
  width: 100%;
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-hover);
}
.btn--outline:hover {
  background: var(--bg-section);
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.sidebar__section--info {
  padding-top: 10px;
  padding-bottom: 10px;
}

/* ================================================================
   SEO & GEO MODAL / GUIDE PANEL
   ================================================================ */
.seo-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.seo-modal[hidden] {
  display: none;
}

.seo-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
}

.seo-modal__content {
  position: relative;
  width: min(640px, 100%);
  max-height: 85vh;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2;
  animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.seo-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-section);
}

.seo-modal__header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.seo-modal__close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.seo-modal__close:hover {
  color: var(--text-primary);
  background: var(--border);
}

.seo-article {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.seo-article h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.seo-article p {
  margin-bottom: 8px;
}

.seo-article ul {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.seo-article a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.seo-article a:hover {
  text-decoration: underline;
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.faq-accordion details {
  background: var(--bg-section);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: border-color var(--t-fast);
}

.faq-accordion details[open] {
  border-color: var(--accent-light);
}

.faq-accordion summary {
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  outline: none;
}

.faq-accordion details p {
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

