
/* =========================================
   BASE LAYOUT — SHARED ACROSS ALL PAGES
========================================= */

/* ---------- 1. DESIGN TOKENS ---------- */

:root {
  color-scheme: light;

  --site-accent: #7652d6;
  --site-accent-hover: #5b3db5;

  --site-text: #242238;
  --site-muted: #77758a;

  --site-background: #ffffff;
  --site-surface: #ffffff;
  --site-surface-muted: #f8f7fc;

  --site-header-background: rgba(255, 255, 255, 0.92);
  --site-border: #e9e5f2;
  --site-footer-background: #f8f7fc;

  --site-container: 1200px;

  --site-radius-sm: 8px;
  --site-radius-md: 14px;
  --site-radius-lg: 20px;

  --site-shadow-sm: 0 4px 14px rgba(35, 24, 65, 0.06);
  --site-shadow-md: 0 12px 32px rgba(35, 24, 65, 0.10);

  --site-transition: 180ms ease;

  --site-focus-ring: 0 0 0 3px rgba(118, 82, 214, 0.30);
}

/* ---------- 2. DARK THEME TOKENS ---------- */

html[data-theme="dark"] {
  color-scheme: dark;

  --site-text: #f0edf8;
  --site-muted: #b8b2c9;

  --site-background: #1d1928;
  --site-surface: #272133;
  --site-surface-muted: #211c2d;

  --site-header-background: rgba(29, 25, 40, 0.94);
  --site-border: #393149;
  --site-footer-background: #191522;

  --site-shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.15);
  --site-shadow-md: 0 12px 32px rgba(0, 0, 0, 0.25);

  --site-focus-ring: 0 0 0 3px rgba(167, 139, 250, 0.40);
}

/* ---------- 3. GLOBAL RESET ---------- */

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

html {
  min-height: 100%;
  background: var(--site-background);
  color: var(--site-text);
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}

body {
  min-height: 100vh;
  margin: 0;

  color: var(--site-text);
  background: var(--site-background);

  font-family: "Inter", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body,
button,
input,
textarea,
select {
  font-family: "Inter", sans-serif;
}

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

img,
picture,
video,
canvas,
svg {
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: inherit;
}

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

::selection {
  color: #ffffff;
  background: var(--site-accent);
}

/* Accessible keyboard focus */

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(118, 82, 214, 0.48);
  outline-offset: 4px;
}

html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] input:focus-visible,
html[data-theme="dark"] textarea:focus-visible,
html[data-theme="dark"] select:focus-visible {
  outline-color: #a78bfa;
}

/* ---------- 4. ACCESSIBLE SKIP LINK ---------- */

.skip-link {
  position: fixed;
  z-index: 10000;
  top: 12px;
  left: 12px;

  padding: 12px 16px;
  border-radius: var(--site-radius-sm);

  background: var(--site-accent);
  color: #ffffff;

  font-weight: 700;
  text-decoration: none;

  transform: translateY(-160%);
  transition: transform var(--site-transition);
}

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

/* ---------- 5. HEADER AND NAVIGATION ---------- */

.site-header {
  position: sticky;
  z-index: 1000;
  top: 0;

  width: 100%;

  border-bottom: 1px solid var(--site-border);
  background: var(--site-header-background);

  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.header-inner {
  width: min(var(--site-container), calc(100% - 48px));
  margin-inline: auto;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;

  min-height: 78px;
  gap: 30px;
}

/* Brand */

.logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;

  color: var(--site-text);

  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.055em;

  text-decoration: none;
}

.logo-name {
  white-space: nowrap;
}

.logo-dot {
  color: var(--site-accent);
}

/* Navigation list */

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;

  margin: 0;
  padding: 0;

  list-style: none;
}

.nav-links > li {
  margin: 0;
  padding: 0;
}

.nav-links > li > a {
  position: relative;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 42px;
  padding: 10px 13px;

  border-radius: 9px;

  color: var(--site-muted);

  font-size: 0.88rem;
  font-weight: 600;

  text-decoration: none;

  transition:
    color var(--site-transition),
    background var(--site-transition);
}

.nav-links > li > a i {
  font-size: 0.83rem;
  opacity: 0.8;
}

.nav-links > li > a:hover {
  color: var(--site-accent);
  background: #f5f1ff;
}

.nav-links > li > a[aria-current="page"] {
  color: var(--site-accent);
  background: #f0eaff;
  font-weight: 750;
}

.nav-links > li > a[aria-current="page"] i {
  opacity: 1;
}

/* Dark navigation states */

html[data-theme="dark"] .nav-links > li > a:hover,
html[data-theme="dark"] .nav-links > li > a[aria-current="page"] {
  color: #c6b1ff;
  background: #302741;
}

html[data-theme="dark"] .site-header {
  border-bottom-color: var(--site-border);
}

/* ---------- 6. THEME SWITCH ---------- */

.theme-nav-item {
  display: flex;
  align-items: center;

  margin-left: 8px;
  padding-left: 15px !important;

  border-left: 1px solid var(--site-border);
}

.theme-switch-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-switch {
  position: relative;

  display: inline-block;

  width: 54px;
  height: 30px;

  cursor: pointer;
}

.theme-switch input {
  position: absolute;

  width: 1px;
  height: 1px;

  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.theme-switch .slider {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 0 7px;
  overflow: hidden;

  border: 1px solid #e4dcef;
  border-radius: 50px;

  background: #f0eaff;
  color: #7c62ba;

  transition:
    background var(--site-transition),
    border-color var(--site-transition);
}

.theme-switch .slider::before {
  position: absolute;
  top: 3px;
  left: 3px;

  width: 22px;
  height: 22px;

  border-radius: 50%;

  background: #ffffff;
  box-shadow: 0 2px 6px rgba(28, 20, 50, 0.16);

  content: "";

  transition:
    transform 250ms ease,
    background 250ms ease;
}

.theme-switch .slider i {
  position: relative;
  z-index: 1;

  font-size: 0.72rem;
  pointer-events: none;
}

.theme-switch input:checked + .slider {
  background: #352b4b;
  border-color: #514267;
  color: #e4d6ff;
}

.theme-switch input:checked + .slider::before {
  transform: translateX(24px);
  background: #a78bfa;
}

.theme-switch input:focus-visible + .slider {
  outline: 3px solid rgba(118, 82, 214, 0.5);
  outline-offset: 4px;
}

/* ---------- 7. MOBILE MENU BUTTON ---------- */

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;

  flex-shrink: 0;

  width: 44px;
  height: 44px;
  padding: 10px;

  border: 1px solid var(--site-border);
  border-radius: 10px;

  background: var(--site-surface);
  color: var(--site-text);

  cursor: pointer;
}

.menu-toggle span {
  display: block;

  width: 19px;
  height: 2px;

  border-radius: 2px;
  background: currentColor;

  transition:
    transform var(--site-transition),
    opacity var(--site-transition);
}

.menu-toggle[aria-expanded="true"] span:first-child {
  transform: translateY(7px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:last-child {
  transform: translateY(-7px) rotate(-45deg);
}

html[data-theme="dark"] .menu-toggle {
  border-color: var(--site-border);
  background: var(--site-surface);
  color: var(--site-text);
}

/* ---------- 8. MAIN CONTENT ---------- */

.site-main {
  min-height: 65vh;
}

.site-main:focus {
  outline: none;
}

/* Shared containers can reuse this class */

.site-container {
  width: min(var(--site-container), calc(100% - 48px));
  margin-inline: auto;
}

/* ---------- 9. TOAST NOTIFICATIONS ---------- */

.toast {
  position: fixed;
  z-index: 2000;
  top: 95px;
  right: 24px;

  width: max-content;
  max-width: min(400px, calc(100% - 32px));

  padding: 14px 18px;

  border: 1px solid var(--site-border);
  border-radius: 12px;

  background: var(--site-surface);
  color: var(--site-text);

  box-shadow: var(--site-shadow-md);

  overflow-wrap: anywhere;
}

.toast:empty {
  display: none;
}

/* Keep this class if main.js uses .show to reveal the toast. */

.toast.show {
  display: block;
}

html[data-theme="dark"] .toast {
  border-color: var(--site-border);
  background: var(--site-surface);
  color: var(--site-text);
}

/* ---------- 10. FOOTER ---------- */

.site-footer {
  padding: 48px 24px 28px;

  border-top: 1px solid var(--site-border);

  background: var(--site-footer-background);
  text-align: center;
}

.footer-inner {
  width: min(100%, 760px);
  margin-inline: auto;
}

.footer-brand {
  display: inline-block;

  margin-bottom: 10px;

  color: var(--site-text);

  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.045em;

  text-decoration: none;
}

.footer-description {
  margin: 0;

  color: var(--site-muted);

  font-size: 0.87rem;
  line-height: 1.8;
}

.footer-divider {
  width: 56px;
  height: 3px;

  margin: 23px auto;

  border-radius: 3px;
  background: var(--site-accent);
}

.footer-copyright {
  margin: 0;

  color: var(--site-muted);

  font-size: 0.8rem;
  line-height: 1.7;
}

html[data-theme="dark"] .logo,
html[data-theme="dark"] .footer-brand {
  color: var(--site-text);
}

/* ---------- 11. TABLET AND MOBILE ---------- */

@media (max-width: 900px) {
  .header-inner {
    width: calc(100% - 36px);
  }

  .navbar {
    min-height: 72px;
    gap: 15px;
  }

  .menu-toggle {
    display: flex;
  }

  .nav-links {
    position: absolute;
    top: calc(100% + 1px);
    right: 0;
    left: 0;

    display: none;
    align-items: stretch;
    flex-direction: column;
    gap: 5px;

    max-height: calc(100vh - 90px);
    overflow-y: auto;

    padding: 16px 18px 20px;

    border-bottom: 1px solid var(--site-border);

    background: var(--site-surface);
    box-shadow: var(--site-shadow-md);
  }

  .nav-links.is-open {
    display: flex;
  }

  .nav-links > li > a {
    justify-content: flex-start;

    width: 100%;
    min-height: 44px;
    padding: 13px 14px;

    font-size: 0.94rem;
  }

  .theme-nav-item {
    justify-content: flex-start;

    margin: 8px 0 0;
    padding: 14px 8px 0 !important;

    border-top: 1px solid var(--site-border);
    border-left: 0;
  }

  html[data-theme="dark"] .nav-links {
    background: var(--site-surface);
  }
}

@media (max-width: 480px) {
  .header-inner,
  .site-container {
    width: calc(100% - 28px);
  }

  .navbar {
    min-height: 66px;
  }

  .logo {
    font-size: 1.05rem;
  }

  .site-footer {
    padding: 38px 18px 24px;
  }

  .footer-description {
    font-size: 0.8rem;
  }

  .toast {
    top: 78px;
    right: 14px;
    max-width: calc(100% - 28px);
  }
}

/* ---------- 12. REDUCED MOTION ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
