/* Starlight Skin Creator — archive & documentation
   Design system. Light palette on :root, dark redefined in both media and
   [data-theme] so the toggle wins in either direction. */

:root {
  --bg:            #f7f7f9;
  --bg-raised:     #ffffff;
  --bg-sunken:     #eceef2;
  --border:        #dcdfe6;
  --border-strong: #c2c7d2;
  --text:          #1b1d23;
  --text-muted:    #5c6472;
  --text-faint:    #868e9e;
  --accent:        #6d3bd4;
  --accent-soft:   #ede6fc;
  --accent-text:   #5a2fb8;
  --ok:            #1f7a4d;
  --ok-soft:       #e2f4ea;
  --warn:          #9a6100;
  --warn-soft:     #fdf0d9;
  --danger:        #b3261e;
  --danger-soft:   #fbe6e5;
  --code-bg:       #f2f3f7;
  --shadow:        0 1px 2px rgba(20, 22, 30, .06), 0 6px 18px rgba(20, 22, 30, .06);
  --radius:        10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0f1116;
    --bg-raised:     #171a21;
    --bg-sunken:     #0a0c10;
    --border:        #262b36;
    --border-strong: #39414f;
    --text:          #e8eaef;
    --text-muted:    #9aa3b2;
    --text-faint:    #6d7686;
    --accent:        #a684f5;
    --accent-soft:   #241b3d;
    --accent-text:   #bda4f8;
    --ok:            #5fcf96;
    --ok-soft:       #12271c;
    --warn:          #e0a53f;
    --warn-soft:     #2b2110;
    --danger:        #f08279;
    --danger-soft:   #2e1614;
    --code-bg:       #12151b;
    --shadow:        0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  --bg:            #0f1116;
  --bg-raised:     #171a21;
  --bg-sunken:     #0a0c10;
  --border:        #262b36;
  --border-strong: #39414f;
  --text:          #e8eaef;
  --text-muted:    #9aa3b2;
  --text-faint:    #6d7686;
  --accent:        #a684f5;
  --accent-soft:   #241b3d;
  --accent-text:   #bda4f8;
  --ok:            #5fcf96;
  --ok-soft:       #12271c;
  --warn:          #e0a53f;
  --warn-soft:     #2b2110;
  --danger:        #f08279;
  --danger-soft:   #2e1614;
  --code-bg:       #12151b;
  --shadow:        0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1180px; margin: 0 auto; padding: .55rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.brand {
  font-weight: 650; letter-spacing: -.015em; color: var(--text);
  text-decoration: none; display: flex; align-items: center; gap: .55rem;
  font-size: .98rem; white-space: nowrap; flex-shrink: 0;
}
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); flex-shrink: 0;
}
.site-nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.site-nav a {
  color: var(--text-muted); text-decoration: none; font-size: .875rem;
  padding: .5rem .7rem; border-radius: 8px; white-space: nowrap;
  display: flex; align-items: center; min-height: 40px;
}
.site-nav a:hover { color: var(--text); background: var(--bg-sunken); }
.site-nav a.active { color: var(--accent-text); background: var(--accent-soft); }

.theme-toggle {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 8px; cursor: pointer; font-size: 1rem; line-height: 1;
  min-width: 40px; min-height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text); }

/* Phones: the brand shortens, the links become a scrollable strip, and every
   tap target keeps a 40px box so nothing needs precision aiming. */
@media (max-width: 620px) {
  .site-header .inner { padding: .5rem .8rem; gap: .6rem; }
  .brand { font-size: 0; gap: 0; }
  .brand::after { content: "Starlight"; font-size: .95rem; margin-left: .5rem; }
  .site-nav {
    gap: .15rem; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch; margin-left: auto;
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .site-nav a { padding: .5rem .55rem; font-size: .82rem; }
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 2.75rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; gap: 1.5rem; } .toc { position: static !important; } }

.toc {
  position: sticky; top: 68px; padding: 2rem 0; font-size: .875rem;
  max-height: calc(100vh - 68px); overflow-y: auto;
}
.toc h4 {
  margin: 1.4rem 0 .5rem; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-faint); font-weight: 650;
}
.toc h4:first-child { margin-top: 0; }
.toc a {
  display: block; padding: .3rem .6rem; color: var(--text-muted);
  text-decoration: none; border-radius: 6px; border-left: 2px solid transparent;
}
.toc a:hover { color: var(--text); background: var(--bg-sunken); }
.toc a.active { color: var(--accent-text); border-left-color: var(--accent); background: var(--accent-soft); }

main { padding: 2rem 0 5rem; min-width: 0; }

/* ---------- Typography ---------- */
h1 { font-size: 2.05rem; line-height: 1.2; letter-spacing: -.025em; margin: 0 0 .6rem; font-weight: 680; }
h2 {
  font-size: 1.4rem; letter-spacing: -.018em; margin: 3rem 0 .9rem; font-weight: 660;
  padding-top: 1.4rem; border-top: 1px solid var(--border);
}
h3 { font-size: 1.06rem; margin: 2rem 0 .6rem; font-weight: 640; letter-spacing: -.01em; }
h4 { font-size: .95rem; margin: 1.4rem 0 .4rem; font-weight: 640; }
p { margin: 0 0 1rem; }
a { color: var(--accent-text); }
.lead { font-size: 1.09rem; color: var(--text-muted); margin-bottom: 1.6rem; }
.meta { font-size: .82rem; color: var(--text-faint); margin: 0 0 2rem; font-family: var(--mono); }
ul, ol { margin: 0 0 1rem; padding-left: 1.3rem; }
li { margin: .3rem 0; }
strong { font-weight: 640; color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

code {
  font-family: var(--mono); font-size: .855em;
  background: var(--code-bg); padding: .13em .38em; border-radius: 4px;
  border: 1px solid var(--border); word-break: break-word;
}
pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem; overflow-x: auto;
  font-size: .845rem; line-height: 1.6; margin: 0 0 1.25rem;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

/* ---------- Components ---------- */
.card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.15rem 1.3rem; margin: 0 0 1.25rem;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.note {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0; padding: .9rem 1.15rem; margin: 0 0 1.25rem;
}
.note.ok     { border-left-color: var(--ok);     background: var(--ok-soft); }
.note.warn   { border-left-color: var(--warn);   background: var(--warn-soft); }
.note.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.note > :last-child { margin-bottom: 0; }
.note .label {
  display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  font-weight: 680; margin-bottom: .3rem; color: var(--accent-text);
}
.note.ok .label     { color: var(--ok); }
.note.warn .label   { color: var(--warn); }
.note.danger .label { color: var(--danger); }

.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .875rem; }
th, td { text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-sunken); font-weight: 640; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-sunken); }
td code { font-size: .82em; }
.num { font-family: var(--mono); text-align: right; white-space: nowrap; }

.grid { display: grid; gap: 1rem; margin: 0 0 1.25rem; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: .95rem 1.1rem; }
.stat .v { font-size: 1.65rem; font-weight: 680; letter-spacing: -.03em; font-family: var(--mono); line-height: 1.15; }
.stat .k { font-size: .76rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-top: .2rem; }
.stat.accent .v { color: var(--accent-text); }
.stat.ok .v { color: var(--ok); }

.pill {
  display: inline-block; font-size: .72rem; font-weight: 650; padding: .16em .55em;
  border-radius: 20px; letter-spacing: .03em; vertical-align: middle;
}
.pill.ok     { background: var(--ok-soft);     color: var(--ok); }
.pill.warn   { background: var(--warn-soft);   color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info   { background: var(--accent-soft); color: var(--accent-text); }

/* Pixel-art rendering for every skin asset on the site. */
.px { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }

.swatch-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.25rem; }
.swatch { text-align: center; font-family: var(--mono); font-size: .68rem; color: var(--text-muted); }
.swatch .chip { width: 54px; height: 34px; border-radius: 6px; border: 1px solid var(--border-strong); margin-bottom: .25rem; }

.figure { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin: 0 0 1.25rem; }
.figure .frame {
  background: var(--bg-sunken); border-radius: 8px; padding: .8rem; display: flex;
  justify-content: center; align-items: center; min-height: 100px;
  background-image: linear-gradient(45deg, var(--border) 25%, transparent 25%),
                    linear-gradient(-45deg, var(--border) 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, var(--border) 75%),
                    linear-gradient(-45deg, transparent 75%, var(--border) 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}
.figure figcaption, .figure .cap { font-size: .8rem; color: var(--text-muted); margin-top: .7rem; text-align: center; }

.crumb { font-size: .8rem; color: var(--text-faint); margin: 0 0 .6rem; }
.crumb a { color: var(--text-muted); text-decoration: none; }
.crumb a:hover { color: var(--accent-text); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: .9rem; }
.pager a { text-decoration: none; color: var(--text-muted); padding: .55rem .9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-raised); }
.pager a:hover { border-color: var(--accent); color: var(--accent-text); }

.site-footer { border-top: 1px solid var(--border); padding: 2rem 0 3rem; color: var(--text-faint); font-size: .82rem; }
.site-footer .inner { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }

.card-link {
  display: block; text-decoration: none; color: inherit; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem;
  transition: border-color .15s, transform .15s;
}
.card-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-link .step { font-family: var(--mono); font-size: .72rem; color: var(--accent-text); letter-spacing: .08em; text-transform: uppercase; }
.card-link h3 { margin: .3rem 0 .35rem; font-size: 1.02rem; color: var(--text); }
.card-link p { margin: 0; font-size: .875rem; color: var(--text-muted); }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  /* On mobile the table of contents becomes a collapsed disclosure so it does
     not push the article a full screen down. */
  .toc {
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-raised); padding: 0; margin: 1rem 0 0; max-height: none;
  }
  .toc-summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: .8rem 1rem; cursor: pointer; font-weight: 640; font-size: .9rem;
    list-style: none;
  }
  .toc-summary::-webkit-details-marker { display: none; }
  .toc-summary::after { content: "▾"; color: var(--text-faint); transition: transform .15s; }
  details[open] > .toc-summary::after { transform: rotate(180deg); }
  .toc-body { padding: 0 .6rem .7rem; }
  .toc h4 { padding: 0 .4rem; }
  .toc a { padding: .55rem .6rem; }
}
@media (min-width: 901px) {
  .toc-summary { display: none; }
  .toc details, .toc-body { display: contents; }
}

@media (max-width: 620px) {
  body { font-size: 15.5px; }
  .wrap { padding: 0 .9rem; }
  main { padding: 1.2rem 0 3rem; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.2rem; margin-top: 2.2rem; }
  h3 { font-size: 1rem; }
  .lead { font-size: 1rem; }
  pre { padding: .8rem .85rem; font-size: .78rem; border-radius: 8px; }
  .card, .note { padding: .9rem 1rem; }
  .grid.c4, .grid.c3 { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .7rem; }
  .grid.c2 { grid-template-columns: 1fr; }
  .stat { padding: .75rem .85rem; }
  .stat .v { font-size: 1.35rem; }
  .stat .k { font-size: .7rem; }
  th, td { padding: .5rem .6rem; font-size: .84rem; }
  .pager { flex-direction: column; }
  .pager a { text-align: center; }
  .site-footer .inner { flex-direction: column; gap: .4rem; }
  .figure { padding: .8rem; }
  .figure img { max-width: 100%; height: auto; }
}

/* Never let a wide element force the whole page to scroll sideways. */
html, body { max-width: 100%; overflow-x: hidden; }
img, canvas, svg { max-width: 100%; }
