/* ================================
   Phenomena – Sleek Glass UI
   With portrait/landscape image layout switch
   ================================ */

/* ---------- 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: #ffd000;
  --accent-body: #b8980c;
  --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;
  color: var(--text);

  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;

  -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 + first text box 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 ---------- */
.phenomena-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;
}

.phenomena-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 ---------- */
.phenomena-image {
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Portrait/square: normal behavior */
.phenomena-image.is-portrait {
  grid-column: auto;
}

/* Landscape: allow spanning full width when layout-landscape is active */
.phenomena-image.is-landscape {
  grid-column: 1 / -1;
}

.phenomena-image img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: calc(var(--radius) - 6px);
  user-select: none;
}

/* Portrait cap, including squares */
.phenomena-image.is-portrait img {
  max-height: 600px;
}

/* Landscape: no cap */
.phenomena-image.is-landscape img {
  max-height: none;
}

.placeholder {
  width: 100%;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

/* ---------- Text content ---------- */
.text-box-1,
.text-box-2 {
  padding: 16px 18px;
  line-height: 1.45;
  color: var(--text);
}

.text-box-1,
.text-box-2 {
  font-size: clamp(12px, 1.05vw, 16px);
  line-height: 1.35;
}

.text-box-1 p,
.text-box-2 p {
  font-size: clamp(12px, 1.05vw, 16px);
  line-height: 1.35;
  margin: 0 0 8px 0;
}

.text-box-1 p:last-child,
.text-box-2 p:last-child {
  margin-bottom: 0;
}

/* Let text boxes grow naturally */
.text-box-1,
.text-box-2 {
  height: auto;
  overflow: visible;
}

/* ---------- Landscape layout reshuffle ----------
   When image is landscape:
   - Image spans full width
   - Text box 1 spans full width underneath
   - Text box 2 stays full width below
-------------------------------------------------- */
.left-column.layout-landscape {
  grid-template-columns: 1fr;
  grid-template-areas:
    "image"
    "text1"
    "text2";
}

/* Flatten wrapper so children participate as grid items */
.left-column.layout-landscape .left-top {
  display: contents;
}

.left-column.layout-landscape .phenomena-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;
}

/* Make second text box span full width below portrait top row */
.left-column.layout-portrait .text-box-2 {
  width: 100%;
}

/* ---------- 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);
}

/* Codex number: small + grey */
.info-box.info-codex {
  font-size: clamp(12px, 1vw, 15px);
  color: var(--muted);
  letter-spacing: 0.4px;
}

/* Icon padding, icons come from super-styles.css */
.info-box.info-audio,
.info-box.info-tag {
  padding-left: 42px;
}

/* Highlight first two boxes */
.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);
}

/* Download button blending */
.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;
}

.muted,
.vm-muted {
  color: var(--muted);
}

/* ---------- Links inside 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: #ffffff;
}

/* ---------- 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) {
  .left-top {
    grid-template-columns: 1fr;
  }

  .left-column.layout-landscape {
    grid-template-columns: 1fr;
  }

  .phenomena-image img {
    height: auto;
  }

  .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);
}

/* ---------- Micro-anim underline ---------- */
@media (prefers-reduced-motion: no-preference) {
  .info-box a,
  .text-box-1 a,
  .text-box-2 a {
    position: relative;
  }

  .info-box a::after,
  .text-box-1 a::after,
  .text-box-2 a::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 a:hover::after,
  .text-box-1 a:hover::after,
  .text-box-2 a:hover::after {
    transform: scaleX(1);
  }
}

/* ---------- Clickable name box ---------- */
.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);
}