/* ================================
   Flora – Sleek Glass UI (with landscape layout switch)
   ================================ */

/* 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: #1bdf28;
  --accent-body: #44882f;
  --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 { min-height: 100%; background: var(--bg); }

body {
  min-height: 100%;
  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;
  padding: 0;
}

.main-content {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 22px;
  align-items: start;
}

.left-column { display: grid; gap: 22px; }

/* Default portrait layout: image + text side-by-side */
.left-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.right-column {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 18px;
}

/* Cards & Panels */
.flora-image,
.text-box,
.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;
}

.flora-image:hover,
.text-box:hover,
.info-box:hover {
  background: var(--panel-hover);
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

/* Codex number box */
.info-box.info-codex {
  font-size: clamp(12px, 1vw, 15px);
  color: var(--muted);
  letter-spacing: 0.4px;
}

/* ---------- Image ---------- */
.flora-image {
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Portrait/square: normal behavior */
.flora-image.is-portrait { grid-column: auto; }

/* Landscape: allow spanning full width when layout-landscape is active */
.flora-image.is-landscape { grid-column: 1 / -1; }

.flora-image img {
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: calc(var(--radius) - 6px);
  user-select: none;
}

/* Portrait cap (incl squares) */
.flora-image.is-portrait img { max-height: 600px; }

/* Landscape: no cap */
.flora-image.is-landscape img { max-height: none; }

/* ---------- Text ---------- */
.text-box {
  padding: 16px 18px;
  line-height: 1.45;
  color: var(--text);
}

.text-box p {
  font-size: clamp(12px, 1.05vw, 16px);
  line-height: 1.35;
  margin: 0 0 8px 0;
}

.text-box 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 a:hover {
  color: var(--accent);
  text-decoration-color: #ffffff;
}

/* ---------- Landscape layout reshuffle (SINGLE text box) ----------
   When image is landscape:
   - Image spans full width
   - One text box spans full width underneath
-------------------------------------------------- */
.left-column.layout-landscape {
  grid-template-columns: 1fr;
  grid-template-areas:
    "image"
    "text";
}

/* Flatten wrapper so children participate as grid items */
.left-column.layout-landscape .left-top { display: contents; }

.left-column.layout-landscape .flora-image { grid-area: image; }
.left-column.layout-landscape .text-box   { grid-area: text; }

/* 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;
  height: auto;
  overflow-wrap: anywhere;

  font-size: clamp(14px, 1.25vw, 20px);
  letter-spacing: .3px;
}

.info-box a,
.info-box a:visited,
.info-box a:active {
  color: #ffffff;
  text-decoration: none;
  border: none;
  outline: 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);
}

/* First two pop */
.right-column .info-box:nth-child(-n+2) {
  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);
}

/* Region gradient legibility */
.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*="region-"] a { color: #f6f6f6; }

/* Download blends */
.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;

  font-weight: inherit;
  color: inherit;
  text-align: inherit;
  line-height: 1.2;

  -webkit-appearance: none;
  appearance: none;
}

.right-column .info-box:last-child a:hover {
  background: none !important;
  color: var(--accent);
  text-shadow: 0 0 12px color-mix(in srgb, var(--accent) 50%, transparent);
}

.right-column .info-box:last-child a:focus-visible { outline: none; }

/* 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; }
}

@media (max-width: 680px) {
  /* On phones, stack everything */
  .left-top { grid-template-columns: 1fr; }
  .left-column.layout-landscape { grid-template-columns: 1fr; }
  .flora-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 styling (same behavior as your fauna) */
.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);
}
