/* ============================================================
   shared.css — WordUnscrambler site-wide styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;0,900;1,700&family=DM+Mono:wght@400;500&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --ink:        #1a1208;
  --paper:      #faf6ef;
  --cream:      #f2ead8;
  --amber:      #d4820a;
  --amber-lt:   #f5c842;
  --amber-pale: #fef3c7;
  --rust:       #b94a1a;
  --sage:       #4a6741;
  --muted:      #7a6a52;
  --border:     #d6c9a8;
  --white:      #ffffff;

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --shadow-sm:  0 1px 3px rgba(26,18,8,.06);
  --shadow-md:  0 4px 24px rgba(26,18,8,.08), 0 1px 3px rgba(26,18,8,.05);
  --shadow-lg:  0 12px 48px rgba(26,18,8,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 15% 0%, rgba(212,130,10,.07) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(185,74,26,.05) 0%, transparent 55%);
}

/* noise overlay */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.03'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

/* ── NAV ── */
.site-nav {
  position: relative; z-index: 10;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 0;
  height: 56px;
}

.nav-logo {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
  margin-right: 32px;
  white-space: nowrap;
}

.nav-logo span { color: var(--amber); }

.nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
  flex: 1;
  overflow-x: auto;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: all .15s;
}

.nav-link:hover { color: var(--ink); background: var(--cream); }
.nav-link.active { background: var(--amber-pale); color: var(--amber); font-weight: 600; }

/* ── AD UNITS ── */
.ad-unit {
  background: var(--cream);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.ad-728x90  { width: 100%; max-width: 728px; height: 90px; margin: 0 auto; }
.ad-300x250 { width: 300px; height: 250px; }
.ad-300x600 { width: 300px; height: 600px; }

/* ── LAYOUT ── */
.page-header {
  position: relative; z-index: 1;
  padding: 36px 32px 0;
  text-align: center;
}

.page-title {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -.025em;
  line-height: 1;
}

.page-title em { color: var(--amber); font-style: normal; }
.page-subtitle { margin-top: 10px; font-size: 15px; color: var(--muted); }

.page-wrap {
  position: relative; z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 72px;
  display: flex; gap: 32px; align-items: flex-start;
}

.main-col { flex: 1; min-width: 0; }

.sidebar {
  width: 300px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 76px;
}

/* ── CARDS ── */
.card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-md);
}

.card-sm {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.card-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px; font-weight: 700;
  margin-bottom: 6px;
}

.card-hint { font-size: 13px; color: var(--muted); margin-bottom: 20px; }

/* ── FORM ELEMENTS ── */
.input-row { display: flex; gap: 10px; flex-wrap: wrap; }

.text-input {
  flex: 1; min-width: 180px; height: 52px;
  font-family: 'DM Mono', monospace;
  font-size: 20px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 16px;
  background: var(--paper); color: var(--ink); outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.text-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(212,130,10,.14);
}

.btn {
  height: 52px; padding: 0 26px;
  border: none; border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .15s;
  letter-spacing: .01em; white-space: nowrap;
}

.btn-primary { background: var(--amber); color: white; }
.btn-primary:hover { background: #b87009; }
.btn-primary:active { transform: scale(.98); }

.btn-secondary {
  background: var(--cream);
  color: var(--ink);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--amber-pale); border-color: var(--amber); }

.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }

.filter-row {
  display: flex; gap: 16px; margin-top: 14px;
  flex-wrap: wrap; align-items: center;
}

.filter-group {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
}

.filter-group label { cursor: pointer; }

.filter-group select,
.filter-group input[type=text] {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: 12px;
  font-family: 'DM Mono', monospace;
  background: var(--paper); color: var(--ink); outline: none;
  letter-spacing: .04em; text-transform: uppercase;
}

/* ── TABS ── */
.tab-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }

.tab {
  padding: 5px 14px;
  border: 1.5px solid var(--border); border-radius: 20px;
  font-size: 12px; font-family: 'DM Mono', monospace;
  cursor: pointer; background: var(--white); color: var(--muted);
  transition: all .15s; letter-spacing: .04em;
}

.tab:hover { border-color: var(--amber); color: var(--amber); }

.tab.active {
  background: var(--amber); border-color: var(--amber); color: white;
}

/* ── WORD GRID ── */
.word-group { margin-bottom: 26px; }

.group-label {
  font-size: 11px; font-family: 'DM Mono', monospace;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px; margin-bottom: 12px;
}

.words-grid { display: flex; flex-wrap: wrap; gap: 7px; }

.word-chip {
  background: var(--white);
  border: 1.5px solid var(--border); border-radius: 8px;
  padding: 7px 13px;
  font-family: 'DM Mono', monospace;
  font-size: 13px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink); cursor: pointer;
  transition: all .15s; position: relative;
  user-select: none;
}

.word-chip:hover {
  border-color: var(--amber); background: var(--amber-pale);
  color: var(--amber); transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(212,130,10,.15);
}

.word-chip.high-val { border-color: var(--rust); background: #fff5f2; }
.score-pip {
  position: absolute; top: -7px; right: -7px;
  background: var(--rust); color: white;
  font-size: 9px; border-radius: 10px; padding: 1px 5px;
  font-family: 'DM Mono', monospace;
}

/* ── LOADER / EMPTY ── */
.loader {
  display: none; text-align: center; padding: 48px;
  color: var(--muted); font-size: 14px;
}
.loader.on { display: block; }

.spinner {
  display: inline-block; width: 28px; height: 28px;
  border: 3px solid var(--border); border-top-color: var(--amber);
  border-radius: 50%; animation: spin .7s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 64px 24px; color: var(--muted);
}
.empty-icon { font-size: 48px; display: block; margin-bottom: 16px; }
.empty-state h2 { font-family: 'Playfair Display', serif; font-size: 20px; color: var(--ink); margin-bottom: 8px; }
.empty-state p { font-size: 14px; line-height: 1.7; max-width: 340px; margin: 0 auto; }

/* ── DEFINITION PANEL ── */
.def-panel {
  display: none;
  background: var(--amber-pale);
  border: 1.5px solid rgba(212,130,10,.25);
  border-radius: var(--radius-md); padding: 18px 22px;
  margin-bottom: 18px; animation: fadeUp .2s ease;
}
.def-panel.on { display: block; }
.def-word { font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700; margin-bottom: 3px; }
.def-pos { font-size: 12px; color: var(--muted); font-style: italic; margin-bottom: 6px; }
.def-text { font-size: 14px; line-height: 1.65; }
.def-score { font-size: 12px; color: var(--rust); margin-top: 8px; font-family: 'DM Mono', monospace; }

@keyframes fadeUp { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:none; } }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: white;
  padding: 10px 20px; border-radius: 8px;
  font-size: 13px; font-family: 'DM Mono', monospace;
  transition: transform .3s cubic-bezier(.22,1,.36,1); z-index: 999;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── FOOTER ── */
.site-footer {
  position: relative; z-index: 1;
  border-top: 1px solid var(--border);
  padding: 24px 32px; text-align: center;
  font-size: 12px; color: var(--muted);
  display: flex; gap: 20px; justify-content: center; flex-wrap: wrap;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--amber); }

/* ── RESPONSIVE ── */
@media (max-width: 820px) {
  .sidebar { display: none; }
  .page-wrap { padding: 16px 16px 48px; }
  .card { padding: 20px; }
  .site-nav { padding: 0 16px; }
}
