/* =========================================================
   Aoi Neko Publishing site.css
   Organized: Tokens -> Base -> Background -> Layout -> Typography
              Components -> Pages -> Utilities -> Media
   ========================================================= */

/* -------------------------
   Tokens
------------------------- */
:root {
  --bg: #0b0d12;
  --panel: rgba(17, 20, 28, 0.80);
  --text: #e9ecf1;
  --muted: rgba(233, 236, 241, 0.70);
  --line: rgba(233, 236, 241, 0.14);

  --btn: rgba(233, 236, 241, 0.10);
  --btnHover: rgba(233, 236, 241, 0.16);

  --accent: #b5179e;               /* arcane magenta */
  --accent2: #ffb703;              /* ember gold */

  --shadow: 0 22px 80px rgba(0, 0, 0, 0.55);
  --radius: 16px;
  --max: 1080px;

  --serif: ui-serif, Georgia, "Times New Roman", Times, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
           "Apple Color Emoji", "Segoe UI Emoji";
}

/* -------------------------
   Base
------------------------- */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  line-height: 1.5;
}

/* -------------------------
   Background mood layer
------------------------- */
.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 1;
  filter: saturate(1.05);
  background:
    radial-gradient(1200px 700px at 18% 12%, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 62%),
    radial-gradient(900px 600px at 90% 18%, color-mix(in srgb, var(--accent2) 18%, transparent) 0%, transparent 55%),
    radial-gradient(1200px 900px at 35% 120%, rgba(0, 0, 0, 0.35) 0%, transparent 65%);
}

/* -------------------------
   Layout
------------------------- */
.wrap {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px 18px 60px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 18px;
}

/* -------------------------
   Brand / nav
------------------------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo {
  width: 42px;
  height: auto;
  opacity: 0.95;
}

.brand .name {
  font-family: var(--serif);
  font-size: 28px;
  letter-spacing: 0.2px;
}

.brand .tag {
  color: var(--muted);
  font-size: 14px;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

a.navlink {
  text-decoration: none;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
}

a.navlink:hover {
  border-color: var(--line);
  background: var(--btn);
}

a.navlink[aria-current="page"] {
  border-color: var(--line);
  background: var(--btn);
  font-weight: 800;
}

/* -------------------------
   Typography
------------------------- */
h1 {
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.1;
  margin: 12px 0 10px;
}

p.lede {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  max-width: 62ch;
}

.miniTitle {
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0 0 10px;
}

.small {
  color: var(--muted);
  margin: 0 0 14px;
}

.readable { max-width: 72ch; }

/* -------------------------
   Core components
------------------------- */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
  height: 100%;
  overflow: visible;
}

.panel.subtle {
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}

.ctaRow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;

  border-radius: 12px;
  padding: 10px 14px;

  border: 1px solid var(--line);
  color: var(--text);
  background: var(--btn);
  font-weight: 700;
}

.btn:hover { background: var(--btnHover); }

.btn.primary {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 22%, transparent),
    color-mix(in srgb, var(--accent2) 18%, transparent)
  );
}

/* Disabled buttons and disabled links */
.btn.disabled,
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--btn);
  border-style: dashed;
}

a.btn[aria-disabled="true"] { pointer-events: none; }

.btn.disabled:hover,
.btn[aria-disabled="true"]:hover { background: var(--btn); }

/* -------------------------
   Hero
------------------------- */
.hero {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.heroInner {
  padding: 26px 22px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}

.kicker {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* -------------------------
   Grids / stacks
------------------------- */
.aboutStack {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  gap: 14px;
}

/* Extras grid and cards */
.extrasGrid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.extrasCard {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Push button row to bottom for even card heights */
.extrasCard .ctaRow {
  margin-top: auto;
  min-height: 44px;
}

/* Make Extras buttons full width */
.extrasCard .btn {
  width: 100%;
  justify-content: center;
}

/* -------------------------
   Links clusters
------------------------- */
.links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* -------------------------
   Forms
------------------------- */
.input {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  color: var(--text);

  border-radius: 12px;
  padding: 10px 12px;

  font: inherit;
  line-height: 1.2;
}

.input::placeholder { color: var(--muted); }

.input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* -------------------------
   Pages: Books
------------------------- */
.booksGrid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.booksGrid > .panel { height: 100%; }

.bookCard {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  height: 100%;
}

.coverImg {
  width: clamp(110px, 10vw, 170px);
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  border: 1px solid var(--line);
  object-fit: cover;
  display: block;
  flex: 0 0 auto;
}

.coverPh {
  width: 88px;
  height: 128px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent2) 16%, transparent),
    color-mix(in srgb, var(--accent) 16%, transparent)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  flex: 0 0 auto;
}

.bookMeta {
  display: flex;
  flex: 1;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.bookMeta h3 {
  margin: 0 0 4px;
  font-family: var(--serif);
  font-size: 18px;
}

.bookMeta p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.bookMeta .links { margin-top: auto; }

/* Desktop-only hover pop on covers */
@media (hover: hover) and (pointer: fine) {
  .coverImg {
    cursor: zoom-in;
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
    transform-origin: center;
  }

  .coverImg:hover {
    transform: scale(1.08);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
    filter: saturate(1.03);
  }
}

/* Hide lightbox on touch/mobile */
@media (hover: none), (pointer: coarse) {
  .lightbox { display: none; }
}

/* -------------------------
   Pages: Characters and Beastiary
------------------------- */
.characterGrid,
.beastiaryGrid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: stretch;
}

.characterCard,
.beastiaryCard {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.characterImg,
.beastiaryImg {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
}

.characterImgLarge,
.beastiaryImgLarge {
  width: 140px;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

/* -------------------------
   Lore cards
------------------------- */
.loreCard {
  display: block;
  text-decoration: none;
  color: inherit;
}

.loreTitle {
  font-family: var(--serif);
  font-size: 20px;
  margin-top: 4px;
  color: var(--accent);
}

.loreCard:hover .loreTitle { text-decoration: underline; }
.loreCard:hover { border-color: var(--accent); }

/* -------------------------
   Bard note callout
------------------------- */
.bardNote {
  margin-top: 14px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  border-radius: 12px;
  font-style: italic;
}

.bardNote .miniTitle {
  margin-bottom: 8px;
  opacity: 0.95;
}

/* -------------------------
   Credits page
------------------------- */
.contributorCard {
  display: flex;
  gap: 18px;
  align-items: center;
}

.contributorImg {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}

.contributorMeta {
  display: flex;
  flex-direction: column;
}

.contributorName {
  font-family: var(--serif);
  font-size: 22px;
  margin: 4px 0 6px;
}

/* -------------------------
   About page portrait layout
------------------------- */
.aboutGrid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 22px;
  align-items: start;
}

.aboutPortrait {
  position: relative;
  width: 100%;
  max-width: 260px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.02));
}

.aboutPortrait img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  filter: contrast(1.05) saturate(0.95);
}

.aboutBody .miniTitle { margin-bottom: 8px; }
.aboutBody .small { margin-bottom: 12px; }
.aboutBody .small:last-of-type { margin-bottom: 10px; }

.aboutList {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.aboutList li { margin: 6px 0; }

/* -------------------------
   Lightbox
------------------------- */
.lightbox {
  border: none;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
}

.lightbox::backdrop { background: rgba(0, 0, 0, 0.72); }

.lightboxClose {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.lightboxClose:hover { background: rgba(0, 0, 0, 0.5); }

.lightboxImg {
  display: block;
  margin: 7vh auto;
  max-width: min(92vw, 720px);
  max-height: 86vh;
  border-radius: 16px;
  box-shadow: 0 30px 120px rgba(0, 0, 0, 0.55);
}

/* -------------------------
   Footer
------------------------- */
footer {
  margin-top: 26px;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 2px;
}

.sep {
  opacity: 0.7;
  padding: 0 8px;
}

/* -------------------------
   Index controls: Characters and Beastiary
------------------------- */
.characterControls,
.beastiaryControls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.textInput {
  flex: 1 1 260px;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--text);
  outline: none;
}

.textInput::placeholder { color: var(--muted); }

.chipRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chipBtn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--btn);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.chipBtn:hover { background: var(--btnHover); }

.chipBtn.isActive {
  border: 2px solid #ffd54a;
  background: rgba(255, 213, 74, 0.15);
  color: #ffffff;
}

.charBadge {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.charBadge.main {
  border-color: color-mix(in srgb, var(--accent2) 55%, var(--line));
  color: var(--text);
}

.charBadge.incidental {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  color: var(--text);
}

/* -------------------------
   Spoilers (collapsible)
------------------------- */
.spoilerDetails {
  margin-top: 10px;
}

.spoilerSummary {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 12px 14px;
  border-radius: 14px;

  font-weight: 800;
  letter-spacing: 0.2px;

  color: var(--text);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 10%, transparent),
    color-mix(in srgb, var(--accent2) 8%, transparent)
  );

  border: 1px dashed color-mix(in srgb, var(--line) 80%, transparent);
}

.spoilerSummary:hover {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 14%, transparent),
    color-mix(in srgb, var(--accent2) 12%, transparent)
  );
}

/* Hide default marker and use a custom icon */
.spoilerSummary::marker { content: ""; }
.spoilerSummary::before {
  content: "⚠";
  font-size: 14px;
  opacity: 0.85;
}

.spoilerDetails[open] .spoilerSummary {
  border-style: solid;
  background: color-mix(in srgb, var(--panel) 85%, transparent);
}

.spoilerBody {
  margin-top: 12px;
  padding: 14px 14px 6px;

  border-left: 3px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  border-radius: 0 0 12px 12px;
}

/* -------------------------
   Breadcrumbs...
------------------------- */
.breadcrumb {
    color: inherit;
    text-decoration: none;
    opacity: .75;
    transition: opacity .2s ease;
}

.breadcrumb:hover {
    opacity: 1;
}

/* -------------------------
   Media: Responsive
------------------------- */
@media (max-width: 880px) {
  nav { justify-content: flex-start; }
  .heroInner { grid-template-columns: 1fr; }
  .booksGrid { grid-template-columns: 1fr; }

  /* Stack most grids on mobile, keep characterGrid auto-fit */
  .grid:not(.characterGrid) { grid-template-columns: 1fr !important; }

  /* About layout collapses */
  .aboutGrid { grid-template-columns: 1fr; }

  .aboutPortrait {
    max-width: 360px;
    margin: 0 auto;
  }
}

@media (max-width: 520px) {
  .bookCard { flex-direction: column; }

  .coverImg {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
  }

  .characterImgLarge,
  .beastiaryImgLarge {
    width: 110px;
  }
}