/* ═══════════════════════════════════════════
   CRYSTOPA FORGE — RESOURCES
   Spec-sheet typography. Book shell layout.
   No hero. No animations. The luxury is the rigor.
   ═══════════════════════════════════════════ */

/* ─── Reset (inherited from style.css when used together) ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Inherit CF light palette */
  --bg: #faf8f5;
  --bg-alt: #f0ece6;
  --text: #1a1520;
  --text-muted: #6b6370;
  --rule: rgba(26, 21, 32, 0.12);
  --rule-strong: rgba(26, 21, 32, 0.28);
  --gold: #c4882e;
  --magenta: #c4346e;
  --cyan: #2ea8b8;
  --purple: #6e4a8e;

  /* Resources-specific tokens */
  --tree-bg: #f5f1ea;
  --tree-active: #1a1520;
  --tree-active-text: #faf8f5;
  --code-bg: #1a1520;
  --code-text: #e8e4f0;
  --code-comment: #8a8098;
  --code-keyword: #c4882e;

  --topbar-h: 56px;
  --tree-w: 280px;
  --max-prose: 72ch;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 10px;
}

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Instrument Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
}

a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: var(--text); }


/* ═══════════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════════ */

.resources-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  background: rgba(250, 248, 245, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.resources-topbar__brand {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.resources-topbar__divider {
  width: 1px;
  height: 18px;
  background: var(--rule-strong);
}

.resources-topbar__section {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-decoration: none;
}
.resources-topbar__section:hover { color: var(--text); }

.resources-topbar__tree-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
}
.resources-topbar__tree-toggle:hover { background: var(--bg-alt); }

@media (min-width: 1024px) {
  .resources-topbar__tree-toggle { display: none; }
}


/* ═══════════════════════════════════════════
   SHELL — left tree + right pane
   ═══════════════════════════════════════════ */

.resources-shell {
  display: grid;
  grid-template-columns: var(--tree-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
}

@media (max-width: 1023px) {
  .resources-shell { grid-template-columns: 1fr; }
}


/* ─── Left tree ─── */
.resources-tree {
  background: var(--tree-bg);
  border-right: 1px solid var(--rule);
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 1.5rem 0 2rem;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1023px) {
  .resources-tree {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: min(86vw, 360px);
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.32s var(--ease-smooth);
    box-shadow: 8px 0 32px rgba(0,0,0,0.08);
  }
  .resources-tree.is-open { transform: translateX(0); }
}

.resources-tree__label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  padding: 0 1.5rem;
  margin-bottom: 0.75rem;
}

.resources-tree__root { list-style: none; }

.resources-tree__group { padding: 0.25rem 0; }

.resources-tree__group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 0;
  padding: 0.4rem 1.5rem;
  font: inherit;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.resources-tree__group-toggle:hover { background: rgba(0,0,0,0.04); }

.resources-tree__group-toggle svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s var(--ease-smooth);
  opacity: 0.5;
}

.resources-tree__group[data-open="false"] .resources-tree__group-toggle svg {
  transform: rotate(-90deg);
}

.resources-tree__items {
  list-style: none;
  padding: 0.15rem 0 0.5rem;
  border-left: 1px solid var(--rule);
  margin-left: 1.5rem;
}

.resources-tree__group[data-open="false"] .resources-tree__items { display: none; }

.resources-tree__items a {
  display: block;
  padding: 0.32rem 0.85rem 0.32rem 0.85rem;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
}

.resources-tree__items a:hover {
  color: var(--text);
  border-left-color: var(--rule-strong);
}

.resources-tree__items a[aria-current="page"] {
  color: var(--text);
  border-left-color: var(--text);
  font-weight: 600;
}

.resources-tree__items a[data-pending] {
  color: var(--text-muted);
  opacity: 0.55;
  cursor: not-allowed;
}
.resources-tree__items a[data-pending]::after {
  content: 'soon';
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-left: 0.5em;
  padding: 0.06em 0.4em;
  border: 1px solid var(--rule);
  border-radius: 3px;
  vertical-align: 1px;
}
.resources-tree__items a[data-pending]:hover {
  color: var(--text-muted);
  border-left-color: transparent;
  background: none;
}

.resources-tree__signature {
  margin-top: auto;
  padding: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.82rem;
  line-height: 1.5;
}
.resources-tree__signature a {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  text-decoration: none;
  display: block;
  margin-bottom: 0.15rem;
}
.resources-tree__signature span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
}


/* ─── Right pane (the page) ─── */
.resources-page {
  padding: 3rem clamp(1.25rem, 4vw, 4rem) 6rem;
  max-width: calc(var(--max-prose) + 8rem);
}

.resources-breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}
.resources-breadcrumb a { text-decoration: none; }
.resources-breadcrumb a:hover { color: var(--text); }
.resources-breadcrumb__sep { margin: 0 0.5rem; opacity: 0.5; }

.resources-page__h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: clamp(1.7rem, 3.5vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin-bottom: 1rem;
  max-width: 28ch;
}

.resources-page__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}
.resources-page__meta code {
  font-family: inherit;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--text);
}


/* ─── Direct Answer Block ─── */
.resources-page__answer {
  margin-bottom: 3rem;
  padding: 1.4rem 1.5rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--text);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.resources-page__answer p {
  font-size: 1.05rem;
  line-height: 1.65;
  margin: 0;
  max-width: var(--max-prose);
}
.resources-page__answer__label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}


/* ─── Section heading style (h2) ─── */
.resources-page h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.005em;
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}
.resources-page h2:first-child { padding-top: 0; border-top: 0; margin-top: 0; }

.resources-page h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 1.1rem;
  margin: 2rem 0 0.75rem;
}

.resources-page h4 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin: 1.5rem 0 0.6rem;
}

.resources-page p,
.resources-page li {
  max-width: var(--max-prose);
}

.resources-page p { margin-bottom: 1rem; }

.resources-page ul,
.resources-page ol {
  margin: 0.5rem 0 1.25rem 1.4rem;
  padding: 0;
}
.resources-page li { margin-bottom: 0.4rem; }


/* ─── The Spec block (centerpiece) ─── */
.resources-spec {
  margin: 2.5rem 0 3rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.resources-spec__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.25rem;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--rule);
}

.resources-spec__title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text);
}

.resources-spec__copy {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--text);
  color: var(--bg);
  border: 0;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.resources-spec__copy:hover { opacity: 0.92; }
.resources-spec__copy:active { transform: scale(0.98); }
.resources-spec__copy svg { width: 14px; height: 14px; }
.resources-spec__copy.is-copied { background: var(--cyan); }
.resources-spec__copy.is-copied .resources-spec__copy-label::before { content: 'Copied'; }
.resources-spec__copy-label::before { content: 'Copy spec'; }

.resources-spec__body { padding: 1.5rem clamp(1.25rem, 2.5vw, 2rem) 2rem; }
.resources-spec__body > :first-child { margin-top: 0; padding-top: 0; border-top: 0; }


/* ─── Code blocks + inline code ─── */
.resources-page pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84rem;
  line-height: 1.55;
}
.resources-page pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

.resources-page code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88em;
  background: var(--bg-alt);
  padding: 0.1em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--rule);
}


/* ─── Tables ─── */
.resources-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.94rem;
}
.resources-page th,
.resources-page td {
  padding: 0.55rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.resources-page th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  background: var(--bg-alt);
}


/* ─── Conditions block (when this works / when it doesn't) ─── */
.resources-conditions { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin: 1.5rem 0 2rem; }
.resources-conditions h3 { margin-top: 0; }
.resources-conditions__col { padding: 1.2rem 1.4rem; border-radius: var(--radius); border: 1px solid var(--rule); }
.resources-conditions__works { background: rgba(46, 168, 184, 0.06); border-color: rgba(46, 168, 184, 0.3); }
.resources-conditions__nope  { background: rgba(196, 52, 110, 0.05); border-color: rgba(196, 52, 110, 0.25); }
@media (max-width: 720px) { .resources-conditions { grid-template-columns: 1fr; } }


/* ─── Outcome block ─── */
.resources-outcome {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem;
}
.resources-outcome__card {
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-alt);
}
.resources-outcome__label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.4rem;
}
.resources-outcome__value {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
}


/* ─── Related entries ─── */
.resources-related ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
}
.resources-related a {
  display: block;
  padding: 0.9rem 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}
.resources-related a:hover { border-color: var(--text); background: var(--bg-alt); }
.resources-related a[data-pending] { opacity: 0.55; cursor: not-allowed; }
.resources-related a[data-pending]:hover { border-color: var(--rule); background: var(--bg); }
.resources-related__cat {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.3rem;
}
.resources-related__title {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.3;
}


/* ─── Page footer signature ─── */
.resources-signature {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.resources-signature a {
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
  text-decoration: none;
}
.resources-signature a:hover { text-decoration: underline; }


/* ─── Mobile tree backdrop ─── */
.resources-tree-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 21, 32, 0.4);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease-smooth);
}
.resources-tree-backdrop.is-visible { opacity: 1; pointer-events: auto; }
@media (min-width: 1024px) { .resources-tree-backdrop { display: none; } }


/* ─── Print: clean spec sheet ─── */
@media print {
  .resources-topbar, .resources-tree, .resources-spec__copy { display: none; }
  .resources-shell { display: block; }
  .resources-page { padding: 0; max-width: none; }
  .resources-spec { border: 1px solid #000; }
  pre { border: 1px solid #888; }
}
