
/* ---------- shared nav + guide pages ---------- */
.site-head { flex-wrap: wrap; gap: 8px 18px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.9rem; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 0; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin: 20px 0 0; }
.crumbs a { color: var(--muted); }
.guide-link { margin: 10px 0 0; font-size: 0.95rem; }
.guide-link:empty { display: none; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin: 12px 0 0; padding: 0; list-style: none; }
.cards a { display: block; height: 100%; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--accent); background: var(--accent-soft); }
.cards strong { display: block; margin-bottom: 2px; }
.cards span { color: var(--muted); font-size: 0.88rem; }
.section-title { font-size: 1.25rem; letter-spacing: -0.015em; margin: 36px 0 0; }
.updated { color: var(--muted); font-size: 0.85rem; margin: 0 0 16px; }
.note-box { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 6px; margin: 16px 0; font-size: 0.93rem; }
.ratio-calc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ratio-calc .out { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 0.95rem; min-height: 1.5em; }
.field select, .field input[type="text"] { width: 100%; font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.tool-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .tool-grid { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); align-items: start; } }
.tool-controls { display: grid; gap: 12px; }
.tool-controls .field label { margin-bottom: 4px; }
.hint, .tool-info, .tool-note, .legend { color: var(--muted); font-size: 0.85rem; margin: 0; }
.tool-warn { color: var(--warn); font-size: 0.88rem; margin: 0; }
.tool-warn:empty { display: none; }
.file-btn { display: inline-block; text-align: center; cursor: pointer; }
.tool-controls .check { margin-top: 0; }
.tool-stage { display: grid; gap: 8px; justify-items: start; background: var(--stage); padding: 16px; border-radius: 8px; }
.tool-stage canvas { width: 100%; height: auto; max-height: 70vh; border-radius: 4px; background: #000; display: block; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -1px; }
.sw.red { background: rgba(220,38,38,.55); }
.sw.dark { background: rgba(0,0,0,.7); border: 1px solid #7dd3fc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.conv-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.unit-field select { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.unit-row { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: .9rem; }
.unit-row select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }

.fields2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.take-row { display: flex; flex-wrap: wrap; gap: 10px; }
.take-row .btn { text-decoration: none; display: inline-block; }
.tree-frame { background: #080b1f; border-radius: 8px; overflow: hidden; display: flex; justify-content: center; }
.tree-frame iframe { border: 0; width: 100%; max-width: 520px; aspect-ratio: 10 / 17; display: block; }
.snippet, .src-box pre { background: var(--stage); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 0.82rem; margin: 0 0 12px; }
.snippet code, .src-box code { background: none; padding: 0; white-space: pre; }
.src-box pre { max-height: 320px; overflow: auto; margin-top: 10px; }
.src-box summary { cursor: pointer; font-weight: 600; }
.src-box { margin: 0 0 16px; }
@media (max-width: 600px) { .tree-frame iframe { aspect-ratio: 1 / 2; } }

.season-grid { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.season-grid a { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.season-grid a:hover { border-color: var(--accent); }
.season-grid img { width: 100%; height: auto; aspect-ratio: 240 / 270; image-rendering: pixelated; border-radius: 6px; background: #080b1f; }
.season-grid span { color: var(--muted); font-size: 0.9rem; }
.season-grid em { font-style: normal; font-size: 0.8rem; color: var(--muted); margin-top: auto; }

.tree-frame.wide iframe { max-width: 100%; aspect-ratio: 900 / 930; }
@media (max-width: 600px) { .tree-frame.wide iframe { aspect-ratio: 1 / 2; } }
.season-grid.wide { grid-template-columns: minmax(0, 480px); }
.season-grid.wide img { aspect-ratio: 3 / 2; image-rendering: auto; }

.tree-frame.ascii iframe { max-width: 100%; aspect-ratio: 860 / 830; }
@media (max-width: 600px) { .tree-frame.ascii iframe { aspect-ratio: 1 / 1.75; } }

.tree-frame.cat iframe { max-width: 560px; aspect-ratio: 1 / 2.2; }
@media (max-width: 600px) { .tree-frame.cat iframe { aspect-ratio: 1 / 3.7; } }

.tree-frame.doodle iframe { max-width: 760px; aspect-ratio: 760 / 1090; }
@media (max-width: 600px) { .tree-frame.doodle iframe { aspect-ratio: 1 / 3.45; } }

/* tall ASCII scene (imugi tower) */
.tree-frame.tower iframe { max-width: 660px; aspect-ratio: 660 / 1010; }
@media (max-width: 600px) { .tree-frame.tower iframe { aspect-ratio: 1 / 2.35; } }

/* calculator: copy-as-code lines */
.code-card { margin-top: 20px; }
.code-card h2 { font-size: 1.1rem; margin: 0 0 4px; }
.code-list { display: grid; gap: 8px; margin-top: 12px; }
.code-line { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left; width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.code-line:hover, .code-line:focus-visible { border-color: var(--accent); }
.code-line.ok { border-color: var(--accent); background: var(--accent-soft); }
.code-line code { font-size: 0.85rem; background: none; padding: 0; overflow-wrap: anywhere; min-width: 0; }
.code-tag { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.code-state { font-size: 0.78rem; font-weight: 600; color: var(--accent); }
@media (max-width: 600px) { .code-line { grid-template-columns: minmax(0, 1fr) auto; } .code-tag { grid-column: 1 / -1; } }
.prose ol { padding-left: 1.3em; } .prose ol li { margin: 0 0 6px; }

/* 16:9 typed scene */
.tree-frame.video iframe { max-width: 100%; aspect-ratio: 16 / 12; }
@media (max-width: 600px) { .tree-frame.video iframe { aspect-ratio: 1 / 1.62; } }

/* 3:2 print-shaped scene */
.tree-frame.print iframe { max-width: 100%; aspect-ratio: 16 / 14; }
@media (max-width: 600px) { .tree-frame.print iframe { aspect-ratio: 1 / 1.7; } }

/* search box on the animations page */
.anim-search { margin: 4px 0 8px; display: grid; gap: 6px; max-width: 460px; }
.anim-search label { font-size: 0.875rem; font-weight: 600; }
.anim-search input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%; box-sizing: border-box; }
.anim-search input:focus-visible { outline-offset: 0; border-color: var(--accent); }
[hidden] { display: none !important; }

/* logo */
.logo { font-size: 1.12rem; letter-spacing: -0.02em; }
.logo-dot { color: #f59a2e; }

/* ===== sidebar navigation with search ===== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.menu-btn { margin-left: auto; font: inherit; font-size: 0.9rem; font-weight: 600; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.side-panel { display: none; width: 100%; padding: 8px 0 6px; }
.site-head.open .side-panel { display: block; }
.site-search { margin: 4px 0 6px; }
.site-search input { width: 100%; font: inherit; font-size: 0.95rem; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); box-sizing: border-box; }
.site-search input:focus-visible { border-color: var(--accent); outline-offset: 0; }
.search-results { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 2px; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 0.92rem; }
.search-results a:hover, .search-results a:focus-visible { background: var(--accent-soft); }
.search-results small { display: block; color: var(--muted); font-size: 0.76rem; font-weight: 400; margin-top: 2px; }
.search-results .none { padding: 8px 10px; color: var(--muted); font-size: 0.85rem; }
.side-panel .nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 2px 12px; margin: 0; font-size: 0.93rem; }
.nav-title { grid-column: 1 / -1; margin: 14px 0 2px 10px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.side-panel .nav a { padding: 7px 10px; border-radius: 8px; }
.side-panel .nav a:hover { background: var(--accent-soft); color: var(--ink); text-decoration: none; }
.side-panel .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; text-decoration: none; }
.site-head.searching .nav { display: none; }
@media (min-width: 1000px) {
  body { padding-left: 252px; }
  .site-head { position: fixed; top: 0; left: 0; bottom: 0; width: 252px; max-width: none; margin: 0; padding: 22px 14px 24px; flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 14px; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); box-sizing: border-box; z-index: 5; }
  .site-head .logo { padding-left: 8px; }
  .menu-btn { display: none; }
  .side-panel { display: block; padding: 0; }
  .side-panel .nav { grid-template-columns: 1fr; }
  .main { padding-top: 20px; }
}

/* 16:9 scene with a taller control row */
.tree-frame.video.more iframe { aspect-ratio: 16 / 13.3; }
@media (max-width: 600px) { .tree-frame.video.more iframe { aspect-ratio: 1 / 1.86; } }

/* 3:2 toy with sliders */
.tree-frame.jelly iframe { max-width: 100%; aspect-ratio: 16 / 17.4; }
@media (max-width: 600px) { .tree-frame.jelly iframe { aspect-ratio: 1 / 2.42; } }

/* games tab, empty for now */
.games-empty { text-align: center; padding: 40px 24px; }
.games-empty h2 { margin: 6px 0 10px; }
.games-empty p { max-width: 52ch; margin-left: auto; margin-right: auto; }
.games-badge { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; margin: 0; }

/* playable game preview */
.tree-frame.game iframe { max-width: 100%; aspect-ratio: 16 / 12.5; }
@media (max-width: 600px) { .tree-frame.game iframe { aspect-ratio: 1 / 1.7; } }

/* Dragon over Blackridge preview */
.tree-frame.ridge iframe { max-width: 100%; aspect-ratio: 16 / 14.6; }
@media (max-width: 600px) { .tree-frame.ridge iframe { aspect-ratio: 1 / 1.52; } }
@media (max-width: 440px) { .tree-frame.ridge iframe { aspect-ratio: 1 / 2.52; } }

/* Sekigahara from the Ridge preview */
.tree-frame.seki iframe { max-width: 100%; aspect-ratio: auto; height: 960px; }
@media (max-width: 600px) { .tree-frame.seki iframe { aspect-ratio: auto; height: 900px; } }
@media (max-width: 440px) { .tree-frame.seki iframe { aspect-ratio: auto; height: 1000px; } }

/* ---------- language switcher ---------- */
.lang-switch { float: right; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 14px; max-width: 55%; margin: 32px 0 0 12px; font-size: 0.82rem; line-height: 1.4; }
.lang-switch a { color: var(--muted); text-decoration: none; }
.lang-switch a:hover { color: var(--ink); text-decoration: underline; }
.lang-switch [aria-current] { color: var(--ink); font-weight: 700; }
@media (max-width: 600px) { .lang-switch { float: none; justify-content: flex-start; max-width: none; margin: 14px 0 -6px; } }

/* GIF studio: tall tool frame, height is set by the tool through guide.js */
.tree-frame.studio { background: #fff; }
.tree-frame.studio iframe { max-width: 100%; aspect-ratio: auto; height: 1400px; }
@media (max-width: 600px) { .tree-frame.studio iframe { aspect-ratio: auto; height: 2400px; } }

/* Pixel Studio: fixed-height tool frame (the tool fills its own viewport) */
.tree-frame.pixel { background: #101217; }
.tree-frame.pixel iframe { max-width: 100%; aspect-ratio: auto; height: 880px; }
@media (max-width: 600px) { .tree-frame.pixel iframe { aspect-ratio: auto; height: 900px; } }

/* Hindi (Devanagari): fonts that carry the script on Windows, Android and Apple devices */
html[lang="hi"] body { font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Nirmala UI", "Noto Sans Devanagari", "Kohinoor Devanagari", Mangal, Roboto, Arial, sans-serif; line-height: 1.7; }

.nav-group { grid-column: 1 / -1; }
.nav-group > summary.nav-title { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; margin: 10px 0 2px; padding: 8px 10px; border-radius: 8px; user-select: none; }
.nav-group > summary.nav-title::-webkit-details-marker { display: none; }
.nav-group > summary.nav-title::after { content: "\25B8"; font-size: 0.8rem; transition: transform .15s; }
.nav-group[open] > summary.nav-title::after { transform: rotate(90deg); }
.nav-group > summary.nav-title:hover, .nav-group > summary.nav-title:focus-visible { background: var(--accent-soft); color: var(--ink); }
.nav-group > a { display: block; }
@media (prefers-reduced-motion: reduce) { .nav-group > summary.nav-title::after { transition: none; } }
