/* Tin documentation: colours, type, layout. */
:root {
  --bg: #0e1319;
  --bg-2: #141a22;
  --surface: #171e27;
  --surface-2: #1d2631;
  --line: #27323f;
  --line-2: #344255;
  --text: #dfe5ec;
  --text-2: #a4afbc;
  --muted: #76838f;
  --tin: #b9c7d6;        /* the metal */
  --tin-2: #8fa3b8;
  --amber: #e8b04b;      /* molten */
  --amber-2: #f6d58a;
  --blue: #74b7e4;
  --jade: #8fcbb0;
  --peach: #f2a37c;
  --rose: #e49ab3;
  --code-bg: #0b1016;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 14px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
:root[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-2: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --line: #e1e6ec;
  --line-2: #cbd3dd;
  --text: #1b2430;
  --text-2: #4b5665;
  --muted: #7a8694;
  --tin: #5c6f85;
  --tin-2: #7f93a9;
  --amber: #b9780d;
  --amber-2: #d9961f;
  --blue: #1d6fa5;
  --jade: #1f7f5c;
  --peach: #c2541f;
  --rose: #b4466e;
  --code-bg: #0f151c;
  --shadow: 0 10px 30px rgba(20,30,40,.08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; line-height: 1.15; margin: 0; }
p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .9em; }
p code, li code, td code, summary code {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .05em .4em; color: var(--text);
}

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 80%, transparent); border-bottom: 1px solid var(--line);
}
.top-inner { max-width: 1240px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--serif); font-weight: 700; font-size: 1.25rem; }
.brand img { width: 30px; height: 30px; }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 18px; margin-left: 8px; }
.top nav a { color: var(--text-2); font-size: .95rem; }
.top nav a.active, .top nav a:hover { color: var(--text); text-decoration: none; }
.top .spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-size: .9rem; cursor: pointer;
}
.btn:hover { border-color: var(--tin-2); text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, var(--amber), var(--amber-2)); color: #1a1205; border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.theme { width: 38px; height: 38px; padding: 0; justify-content: center; }

/* Landing */
.hero { max-width: 1240px; margin: 0 auto; padding: 72px 20px 36px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2.4rem, 5vw, 4rem); font-weight: 700; }
.hero h1 em { font-style: italic; font-weight: 500; color: var(--amber); }
.hero .lede { font-size: 1.15rem; color: var(--text-2); max-width: 46ch; margin: 18px 0 26px; }
.hero > div { min-width: 0; }
.hero .actions { display: flex; gap: 12px; flex-wrap: wrap; }
.mark { width: 92px; height: 92px; margin-bottom: 18px; filter: drop-shadow(0 8px 24px rgba(232,176,75,.25)); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.pill { font-size: .8rem; color: var(--text-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; background: var(--surface); }
.pill b { color: var(--amber); font-weight: 600; }
.grid { max-width: 1240px; margin: 0 auto; padding: 20px 20px 80px; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 20px 16px; transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--tin-2); transform: translateY(-2px); text-decoration: none; }
.tile h3 { font-size: 1.1rem; margin-bottom: 6px; color: var(--text); }
.tile p { color: var(--text-2); font-size: .93rem; margin: 0; }
.tile .k { font-family: var(--mono); font-size: .8rem; color: var(--amber); display: block; margin-bottom: 10px; }

.tile-wide { grid-column: 1 / -1; background: linear-gradient(135deg, color-mix(in srgb, var(--amber) 14%, var(--surface)), var(--surface)); border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); }
.tile-wide p { max-width: 70ch; }

/* Docs layout */
.docs { max-width: 1240px; margin: 0 auto; padding: 28px 20px 100px; display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; }
.side { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); overflow: auto; padding-right: 6px; font-size: .9rem; }
.side .toc > summary { display: none; }
.side h4 { font-family: var(--sans); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 14px 0 6px; }
.side a { display: block; color: var(--text-2); padding: 4px 10px; border-left: 2px solid transparent; border-radius: 0 6px 6px 0; }
.side a:hover { color: var(--text); text-decoration: none; background: var(--surface); }
.side a.active { color: var(--amber); border-left-color: var(--amber); }
.side .sub { padding-left: 10px; }
.side .sub a { font-size: .84rem; padding: 2px 10px; }
.main { min-width: 0; }
.main > header { margin-bottom: 20px; }
.main > header h1 { font-size: 2.4rem; }
.main > header p { color: var(--text-2); max-width: 70ch; margin-top: 10px; }
.notice {
  display: flex; gap: 12px; align-items: flex-start; border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line));
  background: color-mix(in srgb, var(--amber) 9%, var(--surface)); border-radius: 12px; padding: 12px 16px; font-size: .92rem; margin: 18px 0 28px;
}
.notice b { color: var(--amber); }
section.part { margin-top: 56px; }
section.part > h2 { font-size: 1.9rem; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
section.part > h2 .n { font-family: var(--mono); font-size: .85rem; color: var(--amber); margin-right: 12px; vertical-align: middle; font-weight: 500; }
section.part > .intro { color: var(--text-2); margin-bottom: 18px; max-width: 72ch; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 14px; margin: 14px 0; box-shadow: var(--shadow); }
.card h3 { font-size: 1.25rem; margin-bottom: 6px; display: flex; align-items: baseline; gap: 10px; }
.card h3 .sig { font-family: var(--mono); font-weight: 500; font-size: .78rem; color: var(--tin-2); }
.card > p { color: var(--text-2); margin-bottom: 10px; }
.card > p strong, .deeper strong { color: var(--text); font-weight: 600; }
pre { max-width: 100%; margin: 0 0 10px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow: auto; position: relative; line-height: 1.55; }
pre code { font-variant-ligatures: none; font-size: .85rem; color: #d6dde6; display: block; white-space: pre; tab-size: 4; }
pre .copy { position: absolute; top: 8px; right: 8px; font: 500 .72rem var(--sans); color: #8fa3b8; background: #151d27; border: 1px solid #27323f; border-radius: 6px; padding: 3px 8px; cursor: pointer; opacity: 0; transition: opacity .15s; }
pre:hover .copy { opacity: 1; }
pre .copy:hover { color: #e8b04b; }
.rule { font-size: .9rem; color: var(--text-2); margin: 0 0 8px; padding-left: 1.1rem; }
.rule li { margin: 3px 0; }
.rule li::marker { color: var(--amber); }

/* Deeper (expandable) */
.deeper { border-top: 1px dashed var(--line-2); margin-top: 8px; padding-top: 4px; }
.deeper summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 8px 2px; color: var(--amber); font-weight: 600; font-size: .9rem; user-select: none;
}
.deeper summary::-webkit-details-marker { display: none; }
.deeper summary .arrow { width: 18px; height: 18px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--amber) 60%, var(--line)); display: inline-grid; place-items: center; transition: transform .2s, background .2s; }
.deeper summary .arrow svg { width: 10px; height: 10px; }
.deeper[open] summary .arrow { transform: rotate(90deg); background: color-mix(in srgb, var(--amber) 18%, transparent); }
.deeper summary:hover .arrow { background: color-mix(in srgb, var(--amber) 18%, transparent); }
.deeper .body { padding: 4px 0 8px; animation: fade .25s ease; }
.deeper .body p { color: var(--text-2); font-size: .95rem; }
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Tables */
table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: 6px 0 12px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
td code { white-space: nowrap; }

/* Syntax colours */
.tok-k { color: #e8b04b; font-weight: 600; }      /* keyword */
.tok-t { color: #74b7e4; }                        /* type */
.tok-s { color: #8fcbb0; }                        /* string */
.tok-i { color: #f6d58a; }                        /* interpolation */
.tok-n { color: #f2a37c; }                        /* number, unit */
.tok-c { color: #6b7886; font-style: italic; }    /* comment */
.tok-f { color: #e6edf3; }                        /* call */
.tok-b { color: #c9a7e6; }                        /* builtin */
.tok-a { color: #e49ab3; }                        /* attribute */
.tok-o { color: #9fb0c3; }                        /* operator */

footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 26px 20px; text-align: center; }
footer a { color: var(--text-2); }

@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: 40px; gap: 28px; }
  .hero h1 { font-size: clamp(2.1rem, 9vw, 3rem); }
  .mark { width: 72px; height: 72px; }
  .docs { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 16px; }
  .side { position: static; max-height: none; padding: 0; margin-bottom: 8px; overflow: visible; }
  .side .toc { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 4px 12px; }
  .side .toc > summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; padding: 10px 2px; font-weight: 600; color: var(--text); }
  .side .toc > summary::-webkit-details-marker { display: none; }
  .side .toc > summary::after { content: "▾"; color: var(--amber); transition: transform .2s; }
  .side .toc[open] > summary::after { transform: rotate(180deg); }
  .side .toc > nav { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; padding-bottom: 10px; }
  .side h4 { display: none; }
  .side .sub { display: none; }
  .side a { padding: 7px 8px; border-left: 0; border-radius: 8px; font-size: .9rem; }
  .side a.active { background: color-mix(in srgb, var(--amber) 14%, transparent); }
  .top nav a:nth-child(n+3) { display: none; }
  .top-inner { gap: 12px; padding: 0 16px; }
  .btn { padding: 7px 11px; font-size: .85rem; }
}
@media (max-width: 600px) {
  .card { padding: 14px 14px 10px; }
  .card h3 { flex-wrap: wrap; gap: 4px 10px; font-size: 1.15rem; }
  pre { padding: 12px; }
  pre code { font-size: .8rem; }
  pre .copy { opacity: 1; }
  .main > header h1 { font-size: 1.9rem; }
  section.part > h2 { font-size: 1.5rem; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .side .toc > nav { grid-template-columns: 1fr; }
  .grid { padding-bottom: 48px; }
}
