/* ================================
   Fauna – Sleek Glass UI (v2)
   CSS file (full)
   ================================ */

/* ---------- Theme tokens ---------- */
:root {
  --bg: #0e1013;
  --panel: rgba(255,255,255,0.06);
  --panel-hover: rgba(255,255,255,0.09);
  --panel-border: rgba(255,255,255,0.12);
  --text: #eef2f6;
  --muted: #a9b1ba;
  --accent: #df3c1b;
  --accent-body: #a62b13;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03);
  --shadow-soft: 0 6px 18px rgba(0,0,0,0.28);
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { min-height: 100%; }

html { background: var(--bg); }

body {
  margin: 0;
  padding: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 800px at 10% -10%, color-mix(in srgb, var(--accent-body) 35%, transparent), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(86,98,246,0.06), transparent 60%),
    var(--bg);
  background-repeat: no-repeat;
  background-attachment: fixed, fixed, scroll;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--accent) transparent; }
*::-webkit-scrollbar { height: 8px; width: 8px; }
*::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--accent), rgba(66,167,162,0.6)); border-radius: 20px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Layout ---------- */
.container {
  display: block;
  width: min(1280px, 92vw);
  margin: 28px auto;
}

.main-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 22px;
  align-items: start;
  position: relative;
}

/* Full-width color box above both columns */
.color-box {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  background-image: var(--color-gradient); /* set inline via style attribute */
  background-size: 100% 100%;
  background-repeat: no-repeat;
  overflow: hidden;
}

/* Left column */
.left-column {
  display: grid;
  gap: 22px;
}

/* Default (portrait layout) */
.left-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

/* Right column */
.right-column {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 18px;
}

/* ---------- Cards ---------- */
.fauna-image,
.text-box-1,
.text-box-2,
.info-box {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.fauna-image:hover,
.text-box-1:hover,
.text-box-2:hover,
.info-box:hover {
  background: var(--panel-hover);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

/* ---------- Image ---------- */
.fauna-image {
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Treat squares as portrait (server + JS do this already) */
.fauna-image.is-portrait { grid-column: auto; }
.fauna-image.is-landscape { grid-column: 1 / -1; }

.fauna-image img {
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: calc(var(--radius) - 6px);
  user-select: none;
  transform: scale(1);
  transition: transform .28s ease;
  will-change: transform;
}

/* Keep image size on hover change for future update */
.fauna-image:hover img,
.fauna-image:focus-within img { transform: scale(1); }

/* Portrait (incl. square): cap height so it doesn't dominate */
.fauna-image.is-portrait img { max-height: 600px; }

/* Landscape: let it breathe horizontally */
.fauna-image.is-landscape img { max-height: none; }

/* ---------- Text ---------- */
.text-box-1,
.text-box-2 {
  padding: 16px 18px;
  line-height: 1.45;
}

.text-box-1 p,
.text-box-2 p,
.text-box-1 br,
.text-box-2 br {
  font-size: clamp(12px, 1.05vw, 16px);
  line-height: 1.35;
  margin: 0;
}

/* ---------- Landscape layout reshuffle ----------
   When the image is landscape:
   - Image spans full width
   - The two text boxes sit side-by-side under it
   We achieve this by flattening `.left-top` so its children
   participate directly in the left-column grid.
--------------------------------------------------*/
.left-column.layout-landscape {
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: auto;
  grid-template-areas:
    "image image"
    "text1 text2";
}

/* Flatten the wrapper so its children become grid items */
.left-column.layout-landscape .left-top { display: contents; }

/* Place items into areas */
.left-column.layout-landscape .fauna-image { grid-area: image; }
.left-column.layout-landscape .text-box-1  { grid-area: text1; }
.left-column.layout-landscape .text-box-2  { grid-area: text2; }

/* Keep portrait layout unchanged */
.left-column.layout-portrait .left-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

/* ---------- Info stack ---------- */
.info-box {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px 14px;
  min-height: 58px;
  font-size: clamp(14px, 1.25vw, 20px);
  letter-spacing: .3px;
  overflow-wrap: anywhere;
}

/* ---------- Codex number box: smaller + grey ---------- */
.info-box.info-codex {
  font-size: clamp(12px, 1vw, 15px);
  color: var(--muted);
  letter-spacing: 0.4px;
}

.info-box a,
.info-box a:visited,
.info-box a:active {
  color: #fff;
  text-decoration: none;
  transition: color .2s ease, opacity .2s ease, text-shadow .2s ease;
  text-shadow: 0 0 0 transparent;
}
.info-box a:hover { color: var(--accent); text-shadow: 0 0 18px rgba(66,167,162,0.35); }

.right-column .info-box:nth-child(-n+3) {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03)), var(--panel);
  border: 1px solid rgba(255,255,255,0.18);
}

.info-box[class*="category-"],
.info-box[class*="region-"] {
  color: #f6f6f6;
  border: 1px solid rgba(255,255,255,0.22);
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}
.info-box[class*="category-"] a,
.info-box[class*="region-"] a { color: #f6f6f6; }

.right-column .info-box:last-child { padding: 0; }
.right-column .info-box:last-child a {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 12px 14px;
  background: none !important; border: 0 !important; border-radius: inherit;
  box-shadow: none !important; outline: none; color: inherit;
}

/* ---------- Links in text ---------- */
.text-box-1 a, .text-box-2 a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 2px;
  transition: color .2s ease, text-decoration-color .2s ease;
}
.text-box-1 a:hover, .text-box-2 a:hover { color: var(--accent); text-decoration-color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .main-content { grid-template-columns: 1.6fr 1fr; }
}

@media (max-width: 980px) {
  .main-content { grid-template-columns: 1fr; }
  .right-column { position: static; grid-template-columns: repeat(2, 1fr); }
  .right-column .info-box { min-height: 56px; }

  /* Keep landscape behavior (image full width, texts side-by-side) on tablet */
  .left-column.layout-landscape {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "image image"
      "text1 text2";
  }
}

@media (max-width: 680px) {
  /* On phones, stack everything full width */
  .left-column,
  .left-column.layout-landscape {
    grid-template-columns: 1fr;
    grid-template-areas:
      "image"
      "text1"
      "text2";
  }
  .left-top { display: contents; }
  .fauna-image img { height: clamp(220px, 32vh, 420px); }
  .right-column { grid-template-columns: 1fr; }
}

/* ---------- Focus ring ---------- */
a:focus-visible,
.info-box:focus-within {
  outline: 2px solid transparent;
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent) 70%, transparent),
    0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent),
    var(--shadow-soft);
  border-color: rgba(255,255,255,0.24);
}

/* ---------- Clickable (pronunciation) ---------- */
.info-box.clickable,
.info-box.clickable:hover,
.info-box.clickable:focus,
.info-box.clickable * { text-decoration: none !important; }

.info-box.clickable { cursor: pointer; color: inherit; position: relative; }
.info-box.clickable:hover,
.info-box.clickable:focus {
  outline: none;
  background: var(--panel-hover);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  color: var(--accent);
  text-shadow: 0 0 18px rgba(66,167,162,0.35);
}
.info-box.clickable .info-label { position: relative; display: inline-block; }
.info-box.clickable .info-label::after {
  content: ""; position: absolute; left: 0; bottom: -2px; width: 100%; height: 1px;
  background: currentColor; transform-origin: left; transform: scaleX(0); transition: transform .22s ease;
}
.info-box.clickable:hover .info-label::after,
.info-box.clickable:focus .info-label::after { transform: scaleX(1); }

/* ---------- Mythical special backgrounds (full-page frame) ---------- */

.mythical-decor-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

.mythical-decor {
  position: absolute;
  max-width: 38%;
  max-height: 38%;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.65));
  opacity: 0.98;
  transform-origin: center;
}

/* Theme 1: border (branches framing the whole page) */
.mythical-decor-layer.myth-theme-border .mythical-decor[data-index="1"] {
  top: -6%; left: -4%; transform: rotate(-10deg);
}
.mythical-decor-layer.myth-theme-border .mythical-decor[data-index="2"] {
  top: -6%; right: -4%; transform: scaleX(-1) rotate(-6deg);
}
.mythical-decor-layer.myth-theme-border .mythical-decor[data-index="3"] {
  bottom: -8%; left: -3%; transform: rotate(8deg);
}
.mythical-decor-layer.myth-theme-border .mythical-decor[data-index="4"] {
  bottom: -8%; right: -3%; transform: scaleX(-1) rotate(10deg);
}
.mythical-decor-layer.myth-theme-border .mythical-decor[data-index="5"] {
  bottom: -11%; left: 50%; transform: translateX(-50%) scale(1.05);
}

/* Theme 2: fire-ring (large aura around center of viewport) */
.mythical-decor-layer.myth-theme-fire-ring .mythical-decor[data-index="1"] {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 120%;
  max-height: 120%;
}

/* Theme 3: side-flare (vertical energy left/right edges) */
.mythical-decor-layer.myth-theme-side-flare .mythical-decor[data-index="1"] {
  top: -5%; left: -10%; height: 120%; width: auto;
}
.mythical-decor-layer.myth-theme-side-flare .mythical-decor[data-index="2"] {
  top: -5%; right: -10%; height: 120%; width: auto; transform: scaleX(-1);
}

/* Theme 4: halo (glow above the whole layout) */
.mythical-decor-layer.myth-theme-halo .mythical-decor[data-index="1"] {
  top: -18%; left: 50%;
  transform: translateX(-50%);
  max-width: 130%;
  max-height: 130%;
}

/* Theme 5: bottom-embers (embers/smoke along bottom edge) */
.mythical-decor-layer.myth-theme-bottom-embers .mythical-decor[data-index="1"] {
  bottom: -14%; left: 5%;
}
.mythical-decor-layer.myth-theme-bottom-embers .mythical-decor[data-index="2"] {
  bottom: -16%; left: 50%; transform: translateX(-50%);
}
.mythical-decor-layer.myth-theme-bottom-embers .mythical-decor[data-index="3"] {
  bottom: -14%; right: 5%;
}

/* ---------- Motion safety ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .fauna-image img { transform: none !important; }
}