/* ─── Nook Wallpaper Gallery — matches nooktab.com design system ─────────────
   Dark #070a09 base · neon green #19E37D accent · Space Grotesk + Manrope     */

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

:root {
  --bg:          #070a09;
  --text:        #eef2f0;
  --muted:       rgba(238, 242, 240, 0.6);
  --faint:       rgba(238, 242, 240, 0.4);
  --green:       #19E37D;
  --green-soft:  #3ff39a;
  --grad:        linear-gradient(140deg, #21ef88, #13b466);
  --grad-text:   #06140d;
  --card-border: rgba(255, 255, 255, 0.07);
  --card-bg:     rgba(255, 255, 255, 0.02);
  --radius:      18px;
  --font-head:   'Space Grotesk', sans-serif;
  --font-body:   'Manrope', system-ui, sans-serif;
  --max-w:       1180px;
}

html { scroll-behavior: smooth; scrollbar-gutter: stable; }

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

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: var(--font-body); cursor: pointer; border: none; background: none; }

/* width:100% matters: inside the flex-column .page, auto side margins would
   otherwise disable stretching and shrink-wrap <main> around the grid */
.container { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 28px; }
.hidden { display: none !important; }
.page { position: relative; z-index: 2; min-height: 100vh; display: flex; flex-direction: column; }
.page main { flex: 1; }

/* ─── Backdrop décor (same treatment as the main site) ──────────────────── */
@keyframes nk-aurora {
  0%   { transform: translate(-50%, 0) scale(1);      opacity: .85; }
  50%  { transform: translate(-46%, 18px) scale(1.12); opacity: 1;   }
  100% { transform: translate(-50%, 0) scale(1);      opacity: .85; }
}

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.026) 1px, transparent 1px);
  background-size: 62px 62px;
}
.bg-grid-green {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(120,255,190,0.058) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120,255,190,0.058) 1px, transparent 1px);
  background-size: 62px 62px;
  mask-image: radial-gradient(110% 70% at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(110% 70% at 50% 0%, #000 20%, transparent 75%);
}
.bg-aurora {
  position: fixed; top: -200px; left: 50%; transform: translateX(-50%);
  width: 900px; height: 620px; z-index: 0; pointer-events: none;
  background: radial-gradient(closest-side, rgba(25,227,125,0.16), transparent 70%);
  animation: nk-aurora 14s ease-in-out infinite;
}

/* ─── Nav ────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: rgba(7, 10, 9, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.nav-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 0 28px; height: 72px;
  display: flex; align-items: center; justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 5px; }
.brand-logo {
  width: 32px; height: 34px; object-fit: contain; display: block;
  transition: transform .5s cubic-bezier(.34,1.56,.64,1), filter .4s ease;
}
.brand:hover .brand-logo {
  transform: rotate(-7deg) scale(1.08);
  filter: drop-shadow(0 0 12px rgba(25,227,125,0.6));
}
.brand-word {
  font-family: var(--font-head); font-weight: 700; font-size: 30px;
  line-height: 34px; letter-spacing: -0.02em; color: #fff;
}
.brand-sm .brand-logo { width: 24px; height: 26px; }
.brand-word-sm { font-size: 22px; line-height: 26px; }

.nav-right { display: flex; align-items: center; gap: 26px; }
.nav-link {
  position: relative; font-size: 15px; color: rgba(238,242,240,0.7);
  transition: color .25s ease;
}
.nav-link::after {
  content: ""; position: absolute; left: 0; bottom: -5px; width: 100%; height: 1.5px;
  background: var(--green); transform: scaleX(0); transform-origin: left;
  transition: transform .3s cubic-bezier(.22,.61,.36,1);
}
.nav-link:hover { color: #fff; }
.nav-link:hover::after { transform: scaleX(1); }

/* Primary CTA — green gradient pill with sheen, same as the main site */
@keyframes nk-sheen {
  0%   { transform: translateX(-130%) skewX(-18deg); }
  100% { transform: translateX(230%)  skewX(-18deg); }
}
.btn-cta {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 12px 22px; border-radius: 50px;
  background: var(--grad); color: var(--grad-text);
  font-weight: 700; font-size: 14.5px;
  box-shadow: 0 0 28px rgba(25,227,125,0.4);
  transition: transform .28s cubic-bezier(.22,.61,.36,1), box-shadow .28s ease;
  will-change: transform;
}
.btn-cta:hover { transform: translateY(-2px) scale(1.025); box-shadow: 0 16px 38px -14px rgba(25,227,125,0.7); }
.btn-cta:active { transform: translateY(0) scale(.99); }
.btn-cta::after {
  content: ""; position: absolute; top: 0; left: 0; width: 38%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.45), transparent);
  transform: translateX(-130%) skewX(-18deg); pointer-events: none;
}
.btn-cta:hover::after { animation: nk-sheen .85s ease; }

.chrome-badge {
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.btn-ghost {
  display: block; width: 100%; text-align: center;
  padding: 12px 20px; border-radius: 50px; font-size: 13.5px; font-weight: 600;
  color: rgba(238,242,240,0.7); background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  transition: transform .28s cubic-bezier(.22,.61,.36,1), border-color .28s ease, background .28s ease, color .2s ease;
}
.btn-ghost:hover {
  transform: translateY(-2px); color: #fff;
  border-color: rgba(25,227,125,0.4); background: rgba(25,227,125,0.06);
}

/* ─── Hero ───────────────────────────────────────────────────────────────── */
@keyframes nk-reveal { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }

.hero { padding: 72px 0 34px; text-align: center; animation: nk-reveal .7s cubic-bezier(.22,.61,.36,1) both; }
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--green-soft); margin-bottom: 9px;
}
.hero h1 {
  font-family: var(--font-head); font-weight: 700;
  font-size: clamp(38px, 5.6vw, 64px); line-height: 1.05; letter-spacing: -0.03em; color: #fff;
}
.hero-sub { margin: 16px auto 0; max-width: 480px; color: var(--muted); font-size: 16.5px; }

/* ─── Controls: search + tabs ────────────────────────────────────────────── */
.controls {
  position: sticky; top: 72px; z-index: 15;
  background: linear-gradient(rgba(7,10,9,0.9), rgba(7,10,9,0.82) 70%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 16px 0 18px;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.search-wrap {
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: 460px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px; padding: 13px 20px;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.search-wrap:focus-within {
  border-color: rgba(25,227,125,0.45);
  box-shadow: 0 0 0 3px rgba(25,227,125,0.12), 0 0 24px rgba(25,227,125,0.15);
}
.search-wrap svg { color: var(--faint); flex-shrink: 0; }
.search-wrap input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 15px; color: var(--text); font-family: var(--font-body);
}
.search-wrap input::placeholder { color: var(--faint); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; transition: opacity .25s ease; }
/* While a search query is active, results span every category - dim the tabs
   so it's clear they aren't scoping the results. */
.tabs.searching { opacity: .38; }
.tab {
  padding: 8px 18px; border-radius: 50px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,0.05); color: rgba(238,242,240,0.7);
  border: 1px solid rgba(255,255,255,0.12);
  transition: transform .28s cubic-bezier(.22,.61,.36,1), border-color .28s ease, background .28s ease, color .2s ease;
}
.tab:hover { transform: translateY(-2px); color: #fff; border-color: rgba(25,227,125,0.4); background: rgba(25,227,125,0.06); }
.tab.active {
  background: var(--grad); color: var(--grad-text); border-color: transparent;
  box-shadow: 0 0 20px rgba(25,227,125,0.35);
}

/* ─── Uniform grid — every cell 16:9, rows always align perfectly ────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(262px, 1fr));
  gap: 16px;
  padding: 10px 0 72px;
}
@media (max-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); } }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: var(--card-bg); border: 1px solid var(--card-border);
  opacity: 0; transform: translateY(10px);
  transition: opacity .35s ease, transform .35s cubic-bezier(.22,.61,.36,1),
              border-color .35s ease, box-shadow .35s ease;
  will-change: transform;
  /* The whole card is a <button> now - one click applies to Nook */
  display: block; width: 100%; padding: 0; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
}
.card.visible { opacity: 1; transform: translateY(0); }
.card:hover {
  transform: translateY(-6px);
  border-color: rgba(25,227,125,0.32);
  box-shadow: 0 18px 50px -22px rgba(25,227,125,0.5);
}

/* Fixed 16:9 cell - every card is identical, so rows stay perfectly even no
   matter how many wallpapers a category has or what shape the source is */
.card img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  background: linear-gradient(120deg, rgba(255,255,255,0.035), rgba(255,255,255,0.06), rgba(255,255,255,0.035));
}

.card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(4,7,6,0.85) 0%, rgba(4,7,6,0.25) 45%, transparent 70%);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px; gap: 10px;
  opacity: 0; transition: opacity .25s ease;
}
.card:hover .card-overlay, .card:focus-within .card-overlay { opacity: 1; }

.card-cat {
  color: var(--green-soft); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 3px;
}
.card-label {
  font-family: var(--font-head); color: #fff; font-weight: 600; font-size: 15px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.apply-hint {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: 50px;
  background: var(--grad); color: var(--grad-text);
  font-size: 12.5px; font-weight: 700;
  box-shadow: 0 0 20px rgba(25,227,125,0.35);
  pointer-events: none;
}
.card:active { transform: translateY(-2px) scale(.99); }
.card.applying { border-color: rgba(25,227,125,0.6); }
.card.applying .apply-hint { background: #0d3321; color: var(--green-soft); }
.card.applied { border-color: rgba(25,227,125,0.9); box-shadow: 0 0 0 3px rgba(25,227,125,0.22), 0 18px 50px -22px rgba(25,227,125,0.55); }
.card.applied .card-overlay { opacity: 1; }
.card.applied .apply-hint { background: #0d3321; color: var(--green-soft); }

/* ─── Applied badge: glass disc, gradient ring, drawn-on tick ────────────── */
.applied-badge {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-items: center;
  background: radial-gradient(closest-side, rgba(5,14,9,0.5), rgba(5,14,9,0.12) 60%, transparent 78%);
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.card.applied .applied-badge { opacity: 1; }

.badge-disc, .badge-ring { grid-area: 1 / 1; }

.badge-disc {
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center;
  background:
    linear-gradient(rgba(7,14,10,0.9), rgba(7,14,10,0.9)) padding-box,
    linear-gradient(140deg, #3ff39a, #19E37D 45%, rgba(19,180,102,0.4)) border-box;
  border: 2px solid transparent;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 0 0 6px rgba(25,227,125,0.1),
    0 10px 36px rgba(0,0,0,0.5),
    0 0 34px rgba(25,227,125,0.4);
  transform: scale(.4); opacity: 0;
}
.card.applied .badge-disc {
  animation: nk-badge-pop .55s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes nk-badge-pop {
  0%   { transform: scale(.4);  opacity: 0; }
  60%  { transform: scale(1.07); opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}

/* checkmark draws itself in after the disc lands */
.badge-disc svg { overflow: visible; filter: drop-shadow(0 0 7px rgba(63,243,154,0.7)); }
.badge-disc svg path { stroke: #3ff39a; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; }
.card.applied .badge-disc svg path {
  animation: nk-check-draw .4s .22s cubic-bezier(.65,0,.35,1) forwards;
}
@keyframes nk-check-draw { to { stroke-dashoffset: 0; } }

/* soft ripple ring expanding once behind the disc */
.badge-ring {
  width: 62px; height: 62px; border-radius: 50%;
  border: 1.5px solid rgba(43,241,145,0.55);
  opacity: 0;
}
.card.applied .badge-ring { animation: nk-badge-ripple .9s .1s ease-out both; }
@keyframes nk-badge-ripple {
  0%   { transform: scale(.9);  opacity: .8; }
  100% { transform: scale(1.9); opacity: 0;  }
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 64px 0; color: var(--faint); font-size: 15px; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(0);
  background: rgba(10, 16, 13, 0.96); color: var(--text);
  border: 1px solid rgba(25,227,125,0.3);
  padding: 13px 24px; border-radius: 50px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 24px rgba(25,227,125,0.12);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  z-index: 200; transition: opacity .25s ease, transform .25s ease;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(12px); pointer-events: none; }

/* ─── Fallback modal ─────────────────────────────────────────────────────── */
.fallback {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(4, 6, 5, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.fallback-card {
  position: relative;
  background: #0b100d; border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius); padding: 34px; max-width: 400px; width: 100%; text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 0 60px rgba(25,227,125,0.08);
  animation: nk-reveal .35s cubic-bezier(.22,.61,.36,1) both;
}
.fallback-card h3 {
  font-family: var(--font-head); font-size: 19px; font-weight: 700;
  color: #fff; margin-bottom: 8px; letter-spacing: -0.01em;
}
.fallback-card p { color: var(--muted); font-size: 14px; }
.fallback-cta { justify-content: center; width: 100%; margin-top: 18px; }
.fallback-card .btn-ghost { margin-top: 10px; }
.fallback-close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px;
  border-radius: 50%; color: var(--faint); font-size: 20px; line-height: 1;
  transition: background .2s ease, color .2s ease;
}
.fallback-close:hover { background: rgba(255,255,255,0.07); color: #fff; }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.footer { margin-top: 40px; }
.footer-line {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(25,227,125,0.35) 20%, rgba(25,227,125,0.35) 80%, transparent);
}
.footer-inner {
  padding: 34px 0 40px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.footer-note { font-size: 14px; color: rgba(238,242,240,0.5); }
.footer-note a { color: var(--green-soft); }
.footer-note a:hover { text-decoration: underline; }

/* ─── Responsive + reduced motion ────────────────────────────────────────── */
@media (max-width: 560px) {
  .nav-inner { padding: 0 18px; }
  .nav-link { display: none; }
  .brand-word { font-size: 24px; }
  .hero { padding-top: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
