/* ============================================================
   CHAOS CREW HUB — Biomimetic Cellular Design System
   Primary: #99ffcc | Secondary: #00ff41 | Ink: #001e3c
   ============================================================ */


/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --mint: #99ffcc;
  --neon: #00ff41;
  --navy: #001e3c;
  --navy-mid: #002d5a;
  --navy-light: #003d7a;
  --text: #e8f9f2;
  --text-muted: #8ab8a0;
  --radius: 28px;
  --radius-sm: 14px;
  --rail-w: 240px;
  --font-serif: 'Noto Serif JP', Georgia, serif;
  --font-sans: 'Noto Sans JP', system-ui, sans-serif;
  --shadow: 0 4px 32px rgba(0,255,65,0.10), 0 2px 8px rgba(0,0,0,0.4);
  --shadow-card: 0 8px 40px rgba(0,255,65,0.08), 0 2px 12px rgba(0,0,0,0.35);
}

html {
  font-size: 17px;
  line-height: 1.65;
  scroll-behavior: smooth;
  background: var(--navy);
  color: var(--text);
}

body {
  font-family: var(--font-sans);
  min-height: 100vh;
  background: var(--navy);
  overflow-x: hidden;
}

/* --- Typography --- */
h1, h2, h3, h4, h5 {
  font-family: var(--font-serif);
  color: var(--mint);
  line-height: 1.25;
  font-weight: 600;
}

h1 { font-size: clamp(1.6rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.8rem); margin-top: 2rem; }
h3 { font-size: clamp(1rem, 2vw, 1.3rem); color: var(--neon); }
h4 { font-size: 1rem; color: var(--mint); }

p { margin-bottom: 1rem; }
a { color: var(--mint); text-decoration: underline; text-decoration-color: rgba(153,255,204,0.4); }
a:hover { color: var(--neon); text-decoration-color: var(--neon); }

/* Body content links clearly distinct */
.page-content a { color: var(--neon); text-decoration: underline; }
.page-content a:hover { color: var(--mint); }

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  font-weight: 300;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

/* --- Layout Shell --- */
.site-wrap {
  display: flex;
  min-height: 100vh;
}

.page-body {
  flex: 1;
  min-width: 0;
  margin-left: var(--rail-w);
  display: flex;
  flex-direction: column;
}

/* ============================================================
   LEFT RAIL NAVIGATION
   ============================================================ */
.rail-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--rail-w);
  height: 100vh;
  background: var(--navy-mid);
  border-right: 1px solid rgba(153,255,204,0.12);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.rail-brand {
  padding: 1rem;
  border-bottom: 1px solid rgba(153,255,204,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

.brand-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--mint), var(--neon));
  color: var(--navy);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 50%;
  letter-spacing: 0.05em;
}

/* Nav Details / Summary (the structure lottery requirement) */
.nav-details {
  flex: 1;
}

.nav-details[open] > .nav-menu {
  display: block;
}

.nav-toggle {
  display: none; /* hidden on desktop rail */
  list-style: none;
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-direction: column;
  border: none;
  background: none;
  color: var(--mint);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 44px;
  min-width: 44px;
  width: 44px;
  height: 44px;
}

.nav-toggle::marker,
.nav-toggle::-webkit-details-marker { display: none; }

.toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--mint);
  border-radius: 2px;
  transition: background 0.2s;
  flex-shrink: 0;
}

/* Desktop: show menu links directly */
.nav-menu {
  list-style: none;
  padding: 0.5rem 0;
}

.nav-menu li {
  border-bottom: 1px solid rgba(153,255,204,0.06);
}

.nav-menu li a {
  display: flex;
  align-items: center;
  padding: 0.65rem 1.1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.4;
  transition: background 0.15s, color 0.15s;
  min-height: 44px;
}

.nav-menu li a:hover,
.nav-menu li a[aria-current="page"] {
  background: rgba(153,255,204,0.08);
  color: var(--neon);
}

/* CTA buttons in rail */
.rail-ctas {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid rgba(153,255,204,0.1);
}

/* ============================================================
   CTA BUTTONS (global)
   ============================================================ */
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  min-height: 44px;
  padding: 0 1.2rem;
  white-space: nowrap;
}

.cta-signup {
  background: linear-gradient(135deg, var(--mint), var(--neon));
  color: var(--navy);
  box-shadow: 0 2px 16px rgba(0,255,65,0.35);
}

.cta-signup:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px rgba(0,255,65,0.5);
  color: var(--navy);
}

.cta-login {
  background: transparent;
  color: var(--mint);
  border: 2px solid var(--mint);
}

.cta-login:hover {
  background: rgba(153,255,204,0.1);
  color: var(--neon);
  border-color: var(--neon);
}

.rail-ctas .cta {
  width: 100%;
}

/* ============================================================
   DOT-MATRIX TEXTURE
   ============================================================ */
.dot-matrix {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(circle, rgba(153,255,204,0.18) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.55;
}

/* ============================================================
   HERO (home)
   ============================================================ */
.hero-section {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: stretch;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, rgba(0,255,65,0.05) 100%);
  overflow: hidden;
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  min-height: 70vh;
}

.hero-media {
  position: relative;
  overflow: hidden;
  min-height: 340px;
}

.hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  text-align: center;
  z-index: 2;
  position: relative;
}

.hero-copy h1 {
  margin-bottom: 1rem;
}

.hero-desc {
  font-size: 1.05rem;
  margin-bottom: 1.5rem;
  color: var(--text);
  max-width: 420px;
}

.hero-cta {
  font-size: 1rem;
  padding: 0 2rem;
  min-height: 52px;
}

/* ============================================================
   PAGE BANNER (category / inner pages)
   ============================================================ */
.page-banner {
  position: relative;
  padding: 3rem 2rem;
  background: linear-gradient(135deg, var(--navy-mid), var(--navy));
  overflow: hidden;
  min-height: 200px;
  display: flex;
  align-items: center;
}

.page-banner--slim {
  min-height: 140px;
  padding: 2rem;
}

.banner-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
}

.banner-copy {
  position: relative;
  z-index: 2;
}

.banner-copy h1 {
  margin-bottom: 0.5rem;
}

/* ============================================================
   MAIN CONTENT LAYOUT
   ============================================================ */
main {
  flex: 1;
}

/* Structure lottery: main > article.wrap > section > div */
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.content-section {
  width: 100%;
}

/* Structure lottery: main > article.wrap > section > div */
.page-article {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2.5rem;
  align-items: start;
}

/* ============================================================
   SIDEBAR (left of content)
   ============================================================ */
.sidebar-left {
  position: sticky;
  top: 1.5rem;
  background: var(--navy-mid);
  border: 1px solid rgba(153,255,204,0.12);
  border-radius: var(--radius);
  padding: 1.5rem 1.2rem;
  order: -1;
}

.sidebar-left h2 {
  font-size: 0.95rem;
  margin-top: 0;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-left .subtitle {
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

.aside-links {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.aside-links li a {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  min-height: 44px;
}

.aside-links li a:hover {
  background: rgba(153,255,204,0.1);
  color: var(--neon);
}

.aside-parent a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.5rem;
  min-height: 44px;
  padding: 0 0.25rem;
}

.aside-parent a:hover { color: var(--mint); }

/* ============================================================
   ARTICLE BODY
   ============================================================ */
.article-body {
  min-width: 0;
}

.entry-header {
  margin-bottom: 2rem;
}

.byline {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.byline time {
  color: var(--mint);
}

.stage-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
  background: rgba(153,255,204,0.15);
  color: var(--mint);
  border: 1px solid rgba(153,255,204,0.3);
}

.stage-badge.stage-decision { background: rgba(0,255,65,0.15); color: var(--neon); border-color: rgba(0,255,65,0.3); }
.stage-badge.stage-consideration { background: rgba(153,255,204,0.12); color: var(--mint); }
.stage-badge.stage-awareness { background: rgba(0,30,60,0.3); color: var(--text-muted); }

.entry-hero {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.entry-hero-img {
  width: 100%;
  height: auto;
  display: block;
}

/* ============================================================
   PAGE CONTENT (body copy)
   ============================================================ */
.page-content {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
}

.page-content h2 { margin-top: 2rem; margin-bottom: 0.25rem; }
.page-content h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
.page-content ul, .page-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.page-content li { margin-bottom: 0.4rem; line-height: 1.65; }
.page-content blockquote {
  border-left: 3px solid var(--neon);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  background: rgba(0,255,65,0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}
.page-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
.page-content table th {
  background: rgba(153,255,204,0.12);
  color: var(--mint);
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-bottom: 2px solid rgba(153,255,204,0.25);
}
.page-content table td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid rgba(153,255,204,0.08);
  vertical-align: top;
}
.page-content table tr:hover td {
  background: rgba(153,255,204,0.04);
}
.page-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* ============================================================
   CHILD-PAGE CARDS (structure lottery: ul > li > div > h3/p)
   ============================================================ */
.child-grid {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.child-grid > li > div.cell-card {
  background: var(--navy-mid);
  border: 1px solid rgba(153,255,204,0.12);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.child-grid > li > div.cell-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 48px rgba(0,255,65,0.15), 0 4px 16px rgba(0,0,0,0.4);
}

.card-thumb {
  width: 100%;
  height: 170px;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 1.2rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cell-card h3 {
  margin-top: 0;
  font-size: 1rem;
}

.cell-card h3 a {
  color: var(--neon);
  text-decoration: none;
}

.cell-card h3 a:hover {
  color: var(--mint);
}

.cell-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1;
}

.card-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.card-date time {
  color: var(--mint);
}

.card-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--neon);
  text-decoration: none;
  margin-top: 0.75rem;
  letter-spacing: 0.03em;
  min-height: 44px;
}

.card-link:hover { color: var(--mint); }

.sub-links {
  list-style: none;
  padding: 0;
  margin-top: 0.5rem;
}

.sub-links li a {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  padding-left: 0.6rem;
  margin-bottom: 0.2rem;
  min-height: 44px;
  border-left: 2px solid rgba(153,255,204,0.2);
}

.sub-links li a:hover { color: var(--mint); border-color: var(--mint); }

/* ============================================================
   AUTHOR SECTION
   ============================================================ */
.author-section {
  background: var(--navy-mid);
  border: 1px solid rgba(153,255,204,0.15);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 2.5rem;
}

.author-section h2 { margin-top: 0; }

.author-bio {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--navy-mid);
  border-top: 1px solid rgba(153,255,204,0.1);
  margin-top: 3rem;
}

/* Structure lottery: footer contains nav, direct child layer has section container */
.footer-cta-block {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  background: linear-gradient(135deg, rgba(0,255,65,0.04), rgba(153,255,204,0.06));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.footer-cta-label {
  color: var(--mint);
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.5rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(153,255,204,0.07);
  border-bottom: 1px solid rgba(153,255,204,0.07);
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.5rem;
}

.footer-nav a:hover { color: var(--mint); }

.footer-legal {
  text-align: center;
  padding: 1.25rem 1.5rem;
}

.rg-notice {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  line-height: 1.5;
}

.copyright {
  font-size: 0.78rem;
  color: rgba(138,184,160,0.6);
  margin: 0;
}

/* ============================================================
   SCROLL REVEAL ANIMATIONS
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
  }
  .reveal.visible {
    opacity: 1;
    transform: none;
  }
  .stagger-list > * {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease, transform 0.4s ease;
  }
  .stagger-list.visible > * { opacity: 1; transform: none; }
  .stagger-list.visible > *:nth-child(1) { transition-delay: 0.05s; }
  .stagger-list.visible > *:nth-child(2) { transition-delay: 0.1s; }
  .stagger-list.visible > *:nth-child(3) { transition-delay: 0.15s; }
  .stagger-list.visible > *:nth-child(4) { transition-delay: 0.2s; }
  .stagger-list.visible > *:nth-child(5) { transition-delay: 0.25s; }

  /* Breathing animation for accent elements */
  @keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.04); opacity: 1; }
  }
  .brand-glyph {
    animation: breathe 4s ease-in-out infinite;
  }
  .dot-matrix {
    animation: breathe 6s ease-in-out infinite;
  }
}

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 1024px) {
  :root { --rail-w: 200px; }
  .hero-copy { padding: 2rem 1.5rem; }
  .page-article { grid-template-columns: 180px 1fr; gap: 1.5rem; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤768px)
   ============================================================ */
@media (max-width: 768px) {
  :root { --rail-w: 0px; }

  .site-wrap { flex-direction: column; }

  .page-body { margin-left: 0; }

  /* Rail becomes top bar on mobile */
  .rail-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    min-height: 60px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.75rem;
    border-right: none;
    border-bottom: 1px solid rgba(153,255,204,0.12);
    z-index: 200;
    overflow: visible;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .rail-brand {
    padding: 0;
    border-bottom: none;
    flex-shrink: 0;
  }

  /* Ensure brand-mark tap area on mobile */
  .brand-mark {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }

  /* CTA buttons stay visible on mobile header */
  .rail-ctas {
    flex-direction: row;
    padding: 0;
    border-top: none;
    gap: 0.35rem;
    flex-shrink: 0;
    order: 3;
    margin-left: auto;
  }

  .rail-ctas .cta {
    width: auto;
    font-size: 0.72rem;
    padding: 0 0.75rem;
    min-height: 44px;
  }

  /* Show toggle on mobile */
  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    order: 2;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    flex-shrink: 0;
  }

  /* nav-details is part of the mobile row */
  .nav-details {
    order: 2;
    flex-shrink: 0;
  }

  /* Menu drops down below the bar */
  .nav-details[open] > .nav-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--navy-mid);
    border-bottom: 1px solid rgba(153,255,204,0.15);
    z-index: 199;
    display: block;
    padding-bottom: 1rem;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }

  .nav-menu li a {
    font-size: 0.9rem;
    padding: 0.75rem 1.25rem;
    min-height: 44px;
  }

  /* Offset content for fixed top bar */
  .page-body > *:first-child { padding-top: 60px; }
  .hero-section { padding-top: 60px; }
  .page-banner { padding-top: calc(60px + 1.5rem); }
  .page-banner--slim { padding-top: calc(60px + 1rem); }

  /* Hero: stack on mobile */
  .hero-inner {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-media { min-height: 200px; }

  .hero-copy {
    padding: 2rem 1.25rem;
    align-items: flex-start;
    text-align: left;
  }

  /* Sidebar moves below content on mobile */
  .page-article {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .sidebar-left {
    position: static;
    order: 2;
  }

  .article-body { order: 1; }

  .wrap { padding: 1.25rem 1rem; }

  .child-grid { grid-template-columns: 1fr; }

  .footer-nav {
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
  }

  .footer-nav a {
    min-height: 44px;
    padding: 0 0.75rem;
  }
}

/* ============================================================
   NARROW MOBILE (375px)
   ============================================================ */
@media (max-width: 400px) {
  html { font-size: 16px; }
  h1 { font-size: 1.4rem; }
  .rail-ctas .cta { font-size: 0.68rem; padding: 0 0.55rem; min-height: 44px; }
  .hero-copy { padding: 1.5rem 1rem; }
  .wrap { padding: 1rem 0.75rem; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

a[data-cta],button[aria-controls]{min-height:44px;min-width:44px;box-sizing:border-box}main p a{text-decoration:underline}