/* Chrome styling borrowed from the "outside area" of the Supercast App Studio:
   a dotted canvas with a soft gradient and drifting glows, frosted-glass
   panels, white cards with layered shadows, Inter, purple brand, blue selection. */

:root {
  --c-canvas: #f4f3f9;
  --c-dot: rgb(43 58 73 / 0.11);
  --c-grad: linear-gradient(160deg, #eceef8 0%, #fcfcfd 50%, #fbefef 100%);
  --c-g1: rgb(136 128 255 / 0.22);
  --c-g2: rgb(255 141 128 / 0.2);
  --c-g3: rgb(108 91 231 / 0.12);
  --c-glass: rgb(255 255 255 / 0.82);
  --c-panel: #ffffff;
  --c-panel2: #f6f6f8;
  --c-tx: #18181b;
  --c-lt: #6b6b76;
  --c-faint: #9b9ba6;
  --c-ln: #e6e6ea;
  --c-ln2: #d9d9df;
  --c-hover: #f1f1f4;
  --c-sel: #0d99ff;
  --c-sel-soft: rgb(13 153 255 / 0.12);
  --c-brand: #6c5be7;
  --c-brand-d: #5344c1;
  --c-red: #e5484d;
  --c-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 10px 30px -10px rgb(0 0 0 / 0.18);
  --c-shadow-lg: 0 2px 6px rgb(0 0 0 / 0.06), 0 30px 70px -20px rgb(0 0 0 / 0.35);
  --ease-spring: cubic-bezier(0.2, 1.25, 0.3, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-w: 232px;
  --viewer-font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-canvas: #17181d;
    --c-dot: rgb(255 255 255 / 0.07);
    --c-grad: linear-gradient(160deg, #1c1e2c 0%, #151619 50%, #24181b 100%);
    --c-g1: rgb(136 128 255 / 0.16);
    --c-g2: rgb(255 141 128 / 0.11);
    --c-g3: rgb(108 91 231 / 0.12);
    --c-glass: rgb(38 38 43 / 0.82);
    --c-panel: #26262b;
    --c-panel2: #2e2e34;
    --c-tx: #f2f2f5;
    --c-lt: #a6a6b2;
    --c-faint: #7a7a86;
    --c-ln: #36363d;
    --c-ln2: #43434b;
    --c-hover: #313137;
    --c-sel-soft: rgb(13 153 255 / 0.2);
    --c-shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px -10px rgb(0 0 0 / 0.6);
    --c-shadow-lg: 0 2px 6px rgb(0 0 0 / 0.3), 0 30px 70px -20px rgb(0 0 0 / 0.8);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--c-grad) fixed, var(--c-canvas);
  color: var(--c-tx);
  font: 14px/1.5 var(--viewer-font);
  -webkit-font-smoothing: antialiased;
}

/* Canvas: dot grid, with three blurred glows drifting behind everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--c-dot) 1px, transparent 1.4px);
  background-size: 22px 22px;
}

#glow { position: fixed; inset: -12%; z-index: 0; pointer-events: none; }
#glow i { position: absolute; border-radius: 50%; filter: blur(70px); animation: drift 28s ease-in-out infinite alternate; }
#glow i:nth-child(1) { left: 2%; top: 0; width: 55vw; height: 50vh; background: var(--c-g1); }
#glow i:nth-child(2) { right: 0; bottom: 2%; width: 52vw; height: 55vh; background: var(--c-g2); animation-duration: 34s; animation-direction: alternate-reverse; }
#glow i:nth-child(3) { left: 40%; top: 38%; width: 34vw; height: 34vh; background: var(--c-g3); animation-duration: 40s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4vw, 3vh) scale(1.08); }
  100% { transform: translate(-3vw, 5vh) scale(0.95); }
}

:focus-visible { outline: 2px solid var(--c-sel); outline-offset: 2px; }

code {
  font: 500 0.88em var(--mono);
  background: var(--c-panel2);
  padding: 0.12em 0.45em;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px var(--c-ln);
}

a { color: inherit; }

/* Layout ------------------------------------------------------------------ */

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: calc(var(--sidebar-w) + 12px) 1fr;
  min-height: 100vh;
}

/* A floating frosted-glass panel, like the Studio toolbars. */
.sidebar {
  position: sticky;
  top: 12px;
  align-self: start;
  height: calc(100vh - 24px);
  margin: 12px 0 12px 12px;
  padding: 14px 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  border-radius: 16px;
  background: var(--c-glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--c-shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--c-ln);
  font-size: 13px;
  font-weight: 700;
}
.logo {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--c-brand);
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo img { display: block; height: 18px; width: auto; }

.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: block;
  height: 36px;
  line-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 600;
  color: var(--c-lt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.sidebar a:hover { background: var(--c-hover); color: var(--c-tx); }
.sidebar a:active { transform: scale(0.97); }
.sidebar a[aria-current] { background: var(--c-sel-soft); color: var(--c-sel); }

/* Headings of the open file, nested under its sidebar entry. */
.sidebar .outline { margin: 2px 0 8px 18px; padding-left: 6px; border-left: 1px solid var(--c-ln); }
.sidebar .outline a {
  height: 28px;
  line-height: 28px;
  padding: 0 8px 0 calc(8px + var(--depth, 0) * 12px);
  font-size: 12.5px;
  font-weight: 500;
  background: none;
}
.sidebar .outline a:hover { background: var(--c-hover); color: var(--c-tx); }
.sidebar .outline a[aria-current] { background: none; color: var(--c-sel); font-weight: 600; }

/* Content ------------------------------------------------------------------ */

.content { padding: 40px clamp(16px, 5vw, 64px) 96px; max-width: 1100px; }
.content:focus { outline: none; }
.content [id^="sec-"] { scroll-margin-top: 24px; }
.content h2 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 8px; }
.content h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin: 44px 0 16px; }
.content p, .content li { max-width: 65ch; color: var(--c-lt); font-size: 14.5px; }
.content a { color: var(--c-brand); font-weight: 600; }

.error {
  color: var(--c-red);
  padding: 10px 12px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--c-red) 10%, var(--c-panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-red) 30%, transparent);
}
.content p.error { color: var(--c-red); }

/* Tables ------------------------------------------------------------------- */

.table-wrap {
  margin: 16px 0 24px;
  background: var(--c-panel);
  border-radius: 16px;
  box-shadow: var(--c-shadow);
  overflow-x: auto;
}
.content table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.content th, .content td { text-align: left; padding: 12px 16px; vertical-align: top; }
.content th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-lt);
  white-space: nowrap;
  background: var(--c-panel2);
  border-bottom: 1px solid var(--c-ln);
}
.content td { border-bottom: 1px solid var(--c-ln); }
.content tbody tr:last-child td { border-bottom: 0; }
.content tbody tr { transition: background 0.15s; }
.content tbody tr:hover td { background: var(--c-hover); }
.content td:first-child { font-weight: 600; white-space: nowrap; }

/* Preview text input, styled like the Studio inspector fields. */
.preview-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 20px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--c-tx);
  max-width: 520px;
}
.preview-control input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font: 500 13px var(--viewer-font);
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--c-panel);
  color: var(--c-tx);
  box-shadow: var(--c-shadow);
  transition: border-color 0.15s;
}
.preview-control input:hover { border-color: var(--c-ln2); }
.preview-control input:focus { outline: 0; border-color: var(--c-sel); }

/* Font specimens ----------------------------------------------------------- */

.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }

.font-card {
  background: var(--c-panel);
  border-radius: 16px;
  box-shadow: var(--c-shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  transition: transform 0.35s var(--ease-spring), box-shadow 0.3s;
}
.font-card:hover { transform: translateY(-2px); box-shadow: var(--c-shadow-lg); }

.font-card__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-family: var(--viewer-font); }
.font-card__key { order: 0; }
.font-card__name { font-weight: 700; }
.font-card__character { flex-basis: 100%; color: var(--c-lt); font-size: 12.5px; }

.font-card .font-card__hero,
.font-card .font-card__alphabet,
.font-card .font-card__headline,
.font-card .font-card__body { font-family: var(--specimen-font); color: var(--c-tx); margin: 0; max-width: none; }

.font-card .font-card__hero { font-size: 6rem; line-height: 1; }
.font-card .font-card__alphabet { font-size: 1rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.font-card .font-card__headline { font-size: 2rem; line-height: 1.15; }
.font-card .font-card__body { font-size: 1rem; line-height: 1.55; color: var(--c-lt); }

/* Size scale --------------------------------------------------------------- */

.size-scale {
  background: var(--c-panel);
  border-radius: 16px;
  box-shadow: var(--c-shadow);
  margin: 0 0 24px;
  overflow: hidden;
}

.size-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) minmax(0, 260px);
  align-items: baseline;
  gap: 8px 24px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-ln);
  transition: background 0.15s;
}
.size-row:hover { background: var(--c-hover); }
.size-row:last-child { border-bottom: 0; }

.size-row__meta { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.size-row__meta span { font-size: 11.5px; color: var(--c-faint); font-variant-numeric: tabular-nums; }

.content .size-row p { margin: 0; max-width: none; }
.content .size-row .size-row__sample { color: var(--c-tx); line-height: 1.15; overflow-wrap: anywhere; }
.content .size-row .size-row__use { font-size: 12.5px; }

/* Spacing bars reuse the size-scale rows. --space-md is how long the md step
   is drawn; every other step is that times its ratio. */
.size-scale { --space-md: 40px; }
.space-bar-track { align-self: center; min-width: 0; }
.space-bar {
  width: calc(var(--space-md) * var(--ratio));
  height: 20px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--c-brand) 22%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--c-brand);
}

/* Small screens ------------------------------------------------------------ */

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; margin: 12px; padding: 10px; }
  .brand { margin-bottom: 8px; padding-bottom: 10px; }
  .sidebar ul { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar .outline { display: none; }
  .size-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  #glow i { animation: none; }
  * { transition: none !important; }
}
