/* Importing Google Fonts - Karla + Fraunces */
@import url("https://fonts.googleapis.com/css2?family=Karla:wght@400;500;600;700;800&family=Fraunces:ital,opsz,wght@1,9..144,600&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Karla", sans-serif;
}

:root {
  --bg: #faf5ee;
  --card: #fffdf9;
  --text: #2b1d14;
  --muted: #7a6758;
  --border: #eadfd2;
  --accent: #c2410c;
  --accent-soft: #fdeee3;
  --on: #15803d;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Demo page ---------- */
.demo {
  max-width: 760px;
  margin: 0 auto;
  padding: 80px 20px 260px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.demo h1 {
  margin: 12px 0;
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.demo h1 em {
  font-family: "Fraunces", serif;
  color: var(--accent);
}

.demo > p {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.panel {
  margin-top: 34px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  gap: 6px;
}

.panel-actions button {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

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

.states li {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f5ede3;
  font-size: 0.85rem;
  font-weight: 700;
}

.states li small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 600;
}

.states li.on small {
  color: var(--on);
}

.log {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #2b1d14;
  color: #f3e6d8;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.8;
  list-style: none;
}

.log li {
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

/* ---------- Buttons ---------- */
.btn {
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn.solid {
  border: 0;
  background: var(--text);
  color: #fff;
}

.btn.solid:hover {
  box-shadow: 0 10px 24px -12px rgba(43, 29, 20, 0.8);
}

.btn.outline {
  border: 1.5px solid var(--text);
  background: none;
  color: var(--text);
}

.btn.ghost {
  border: 0;
  background: none;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn:focus-visible,
.switch input:focus-visible + .slider,
.cat-toggle:focus-visible,
.close:focus-visible,
.reopen:focus-visible {
  outline: 3px solid rgba(194, 65, 12, 0.45);
  outline-offset: 2px;
}

/* ---------- Banner ---------- */
.banner {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
  width: min(480px, calc(100% - 32px));
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 30px 70px -30px rgba(43, 29, 20, 0.45);
  animation: slideUp 0.6s var(--ease);
}

.banner.is-leaving {
  animation: slideDown 0.35s var(--ease) forwards;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
}

@keyframes slideDown {
  to {
    opacity: 0;
    transform: translateY(40px);
  }
}

.cookie-art {
  font-size: 2.6rem;
  line-height: 1;
  animation: wobble 2.4s ease-in-out infinite;
}

@keyframes wobble {
  0%,
  100% {
    transform: rotate(0);
  }
  20% {
    transform: rotate(-14deg);
  }
  40% {
    transform: rotate(10deg);
  }
  60% {
    transform: rotate(-4deg);
  }
}

.banner h2 {
  font-size: 1.15rem;
  font-weight: 800;
}

.banner p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.gpc-note {
  padding: 8px 10px;
  border-radius: 10px;
  background: #ecfdf3;
  color: #166534 !important;
}

.banner-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* ---------- Preference center ---------- */
.prefs {
  width: min(600px, calc(100% - 24px));
  max-height: min(760px, calc(100vh - 32px));
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 40px 100px -30px rgba(43, 29, 20, 0.5);
}

.prefs[open] {
  animation: pop 0.3s var(--ease);
}

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

.prefs::backdrop {
  background: rgba(43, 29, 20, 0.4);
  backdrop-filter: blur(3px);
}

.prefs-box {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.prefs-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 24px 0;
}

.prefs-head h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

.close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f5ede3;
  color: var(--muted);
  cursor: pointer;
}

.prefs-intro {
  padding: 8px 24px 16px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.cats {
  display: grid;
  gap: 10px;
  padding: 0 24px 16px;
  overflow-y: auto;
}

.cat {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fffaf4;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.cat-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.cat-toggle .chev {
  color: var(--muted);
  transition: transform 0.3s var(--ease);
}

.cat-toggle[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.cat-toggle b {
  display: block;
  font-size: 0.98rem;
}

.cat-toggle small {
  color: var(--muted);
  font-size: 0.82rem;
}

.always {
  color: var(--on);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

/* Switch */
.switch {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.slider {
  display: block;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #d6c8ba;
  transition: background 0.25s;
}

.slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.25s var(--ease);
}

.switch input:checked + .slider {
  background: var(--on);
}

.switch input:checked + .slider::after {
  transform: translateX(20px);
}

/* Cookie details */
.cat-details {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s var(--ease);
}

.cat-details > div {
  overflow: hidden;
}

.cat.is-open .cat-details {
  grid-template-rows: 1fr;
}

.cat-details p {
  padding: 0 16px 10px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.cookies {
  width: calc(100% - 32px);
  margin: 0 16px 14px;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.cookies th,
.cookies td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.cookies th {
  color: var(--muted);
  font-weight: 700;
}

.cookies code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
}

.prefs-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}

.prefs-foot div {
  display: flex;
  gap: 8px;
}

/* ---------- Reopen button ---------- */
.reopen {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 30;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  font-size: 1.5rem;
  box-shadow: 0 14px 30px -14px rgba(43, 29, 20, 0.5);
  cursor: pointer;
  animation: slideUp 0.5s var(--ease);
  transition: transform 0.25s var(--ease);
}

.reopen:hover {
  transform: rotate(-20deg) scale(1.08);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--text);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 0.3s, transform 0.3s var(--ease);
  pointer-events: none;
}

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

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    grid-template-columns: 1fr;
  }

  .cookie-art {
    display: none;
  }

  .banner-actions .btn {
    flex: 1;
  }

  .states {
    grid-template-columns: repeat(2, 1fr);
  }

  .prefs-foot,
  .prefs-foot div {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .cookies th:nth-child(3),
  .cookies td:nth-child(3) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
