@layer reset, tokens, base, layout, components, views, motion, responsive;

@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    color-scheme: dark;
    scroll-behavior: smooth;
  }

  html[data-skin="aletheia"] {
    color-scheme: light;
  }

  body,
  h1,
  h2,
  h3,
  p,
  ul,
  ol,
  pre {
    margin: 0;
  }

  button,
  input,
  select,
  textarea {
    color: inherit;
    font: inherit;
  }

  input[type="number"] {
    appearance: textfield;
  }

  input[type="number"]::-webkit-inner-spin-button,
  input[type="number"]::-webkit-outer-spin-button,
  input[type="password"]::-ms-clear,
  input[type="password"]::-ms-reveal {
    display: none;
  }

  button,
  a {
    -webkit-tap-highlight-color: transparent;
  }

  button {
    border: 0;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  svg {
    display: block;
  }

  [hidden] {
    display: none !important;
  }
}

@layer tokens {
  :root {
    --font-ui: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei UI", system-ui, sans-serif;
    --font-display: "Arial Narrow", "Bahnschrift Condensed", "DIN Alternate", var(--font-ui);
    --font-data: "Cascadia Mono", "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    --font-sacred: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;

    --canvas: #070c0e;
    --canvas-rgb: 7, 12, 14;
    --surface-1: #0e1518;
    --surface-2: #151f22;
    --surface-3: #1c282c;
    --surface-glass: rgba(15, 23, 26, 0.82);
    --text-1: #f1f4f1;
    --text-2: #a3aeab;
    --text-3: #6f7c79;
    --placeholder: #7b8885;
    --line: rgba(226, 236, 231, 0.14);
    --line-strong: rgba(226, 236, 231, 0.34);
    --accent: #e8f10c;
    --accent-rgb: 232, 241, 12;
    --accent-ink: #090c0d;
    --accent-secondary: #3159e8;
    --scan: #30d6b0;
    --status-success: #2bcf9b;
    --status-warning: #d99a2b;
    --status-danger: #e34b57;
    --status-info: #3974d8;
    --glow: rgba(232, 241, 12, 0.2);
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.4);
    --sidebar-width: 232px;
    --topbar-height: 64px;
    --page-gutter: clamp(22px, 3vw, 52px);
    --radius-tight: 5px;
    --radius-panel: 12px;
    --radius-soft: 22px;
    --ease-mechanical: cubic-bezier(0.2, 0.75, 0.25, 1);
    --ease-ceremonial: cubic-bezier(0.16, 1, 0.3, 1);
  }

  html[data-skin="aletheia"] {
    --canvas: #eef3f6;
    --canvas-rgb: 238, 243, 246;
    --surface-1: #fafcfd;
    --surface-2: #e6edf2;
    --surface-3: #dce6ed;
    --surface-glass: rgba(250, 252, 253, 0.84);
    --text-1: #27323b;
    --text-2: #617080;
    --text-3: #88949f;
    --placeholder: #748492;
    --line: rgba(65, 83, 101, 0.13);
    --line-strong: rgba(65, 83, 101, 0.3);
    --accent: #66577d;
    --accent-rgb: 102, 87, 125;
    --accent-ink: #ffffff;
    --accent-secondary: #a8c8e4;
    --scan: #8e82ad;
    --glow: rgba(170, 201, 228, 0.34);
    --shadow: 0 22px 68px rgba(61, 81, 101, 0.12);
  }
}

html:not([data-surface="admin"]) .admin-surface-only,
html[data-surface="admin"] .member-surface-only {
  display: none !important;
}

@layer base {
  body {
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--canvas);
    color: var(--text-1);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.6;
    transition: background-color 600ms var(--ease-ceremonial), color 400ms ease;
  }

  html[data-boot-transitions="suspended"] body,
  html[data-boot-transitions="suspended"] body > :not(.boot-sequence),
  html[data-boot-transitions="suspended"] body > :not(.boot-sequence) *,
  html[data-boot-transitions="suspended"] body > :not(.boot-sequence)::before,
  html[data-boot-transitions="suspended"] body > :not(.boot-sequence)::after,
  html[data-boot-transitions="suspended"] body > :not(.boot-sequence) *::before,
  html[data-boot-transitions="suspended"] body > :not(.boot-sequence) *::after {
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }

  ::selection {
    background: var(--accent);
    color: var(--accent-ink);
  }

  ::placeholder {
    color: var(--placeholder);
    opacity: 1;
  }

  :focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }

  ::-webkit-scrollbar {
    width: 9px;
    height: 9px;
  }

  ::-webkit-scrollbar-track {
    background: var(--canvas);
  }

  ::-webkit-scrollbar-thumb {
    border: 3px solid var(--canvas);
    background: var(--line-strong);
  }

  * {
    scrollbar-color: var(--line-strong) var(--canvas);
    scrollbar-width: thin;
  }

  input:-webkit-autofill,
  input:-webkit-autofill:hover,
  input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-1);
    caret-color: var(--text-1);
    box-shadow: 0 0 0 1000px rgba(var(--canvas-rgb), 0.96) inset;
    transition: background-color 600000s 0s, color 600000s 0s;
  }

  .skip-link {
    position: fixed;
    z-index: 1000;
    top: 12px;
    left: 12px;
    padding: 9px 14px;
    background: var(--accent);
    color: var(--accent-ink);
    transform: translateY(-160%);
  }

  .skip-link:focus {
    transform: translateY(0);
  }
}

@layer layout {
  .app-shell {
    position: relative;
    z-index: 2;
    display: grid;
    min-height: 100vh;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    z-index: 50;
    inset: 0 auto 0 0;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    padding: 26px 18px 22px;
    border-right: 1px solid var(--line);
    background:
      linear-gradient(180deg, rgba(var(--accent-rgb), 0.035), transparent 30%),
      rgba(var(--canvas-rgb), 0.94);
    backdrop-filter: blur(22px);
    transition: background 600ms var(--ease-ceremonial), border-color 400ms ease, transform 350ms var(--ease-ceremonial);
  }

  .workspace {
    position: relative;
    min-width: 0;
    grid-column: 2;
  }

  .topbar {
    position: sticky;
    z-index: 40;
    top: 0;
    display: flex;
    height: var(--topbar-height);
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 0 var(--page-gutter);
    border-bottom: 1px solid var(--line);
    background: rgba(var(--canvas-rgb), 0.78);
    backdrop-filter: blur(20px) saturate(1.2);
    transition: background 600ms var(--ease-ceremonial), border-color 400ms ease;
  }

  main {
    position: relative;
    width: 100%;
  }

  .view {
    width: min(100%, 1660px);
    min-height: calc(100vh - var(--topbar-height));
    margin: 0 auto;
    padding: clamp(28px, 3.4vw, 52px) var(--page-gutter) 80px;
  }

  .view.is-leaving {
    pointer-events: none;
  }

  .view-heading {
    position: relative;
    margin-bottom: clamp(24px, 2.6vw, 38px);
  }

  .view-heading--split {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 32px;
  }

  .view-heading h1 {
    max-width: 720px;
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(28px, 2.3vw, 38px);
    font-stretch: condensed;
    font-weight: 560;
    letter-spacing: -0.025em;
    line-height: 1.1;
  }

  .view-heading h1 em {
    color: var(--text-2);
    font-style: normal;
    font-weight: 350;
  }

  .view-heading .lede {
    max-width: 610px;
    margin-top: 10px;
    color: var(--text-2);
    font-size: 13px;
    letter-spacing: 0.015em;
  }
}
