/* ==========================================================================
   ClassNotes — Minimalist Editorial White Design System
   Shared across public notes view & admin console
   ========================================================================== */

:root {
  /* Pure & Layered White Surfaces */
  --bg-page: #fafaf9;
  --bg-surface: #ffffff;
  --bg-subtle: #f5f6f8;
  --bg-muted: #eef0f4;
  --bg-glass: rgba(255, 255, 255, 0.82);

  /* Ink Typography Scale */
  --ink-primary: #111827;
  --ink-secondary: #4b5563;
  --ink-muted: #8b95a5;
  --ink-faint: #b4bcc9;

  /* Crisp Borders */
  --border-hairline: rgba(15, 23, 42, 0.07);
  --border-subtle: rgba(15, 23, 42, 0.11);
  --border-strong: rgba(15, 23, 42, 0.2);

  /* Refined Accents */
  --accent-ink: #18181b;
  --accent-ink-hover: #27272a;
  --accent-blue: #2563eb;
  --accent-blue-soft: #eff6ff;
  --accent-green: #15803d;
  --accent-green-soft: #f0fdf4;
  --accent-amber: #b45309;
  --accent-amber-soft: #fffbeb;
  --accent-rose: #be123c;
  --accent-rose-soft: #fff1f2;
  --accent-violet: #6d28d9;
  --accent-violet-soft: #f5f3ff;

  /* Layered Delicate Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 2px 6px rgba(15, 23, 42, 0.04), 0 12px 32px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 48px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.05);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-pill: 999px;

  /* Motion */
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 180ms;
  --duration-base: 300ms;
  --duration-slow: 480ms;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink-primary);
  background-color: var(--bg-page);
  line-height: 1.65;
  overflow-x: hidden;
  min-height: 100vh;
}

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

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

button {
  cursor: pointer;
}

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ==========================================================================
   Ambient White Header Glow (Subtle, luminous, never heavy)
   ========================================================================== */

.ambient-backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(62% 45% at 15% -5%, rgba(219, 234, 254, 0.42) 0%, rgba(255, 255, 255, 0) 70%),
    radial-gradient(50% 40% at 88% 0%, rgba(237, 233, 254, 0.34) 0%, rgba(255, 255, 255, 0) 68%),
    linear-gradient(180deg, #ffffff 0%, #fafaf9 38%, #f8f9fb 100%);
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.45;
  animation: ambientFloat 18s ease-in-out infinite alternate;
}

.ambient-orb--one {
  width: 420px;
  height: 420px;
  top: -180px;
  left: -80px;
  background: radial-gradient(circle, rgba(191, 219, 254, 0.65), transparent 70%);
}

.ambient-orb--two {
  width: 380px;
  height: 380px;
  top: -140px;
  right: -90px;
  background: radial-gradient(circle, rgba(221, 214, 254, 0.55), transparent 70%);
  animation-delay: -7s;
}

@keyframes ambientFloat {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(28px, 18px, 0) scale(1.06);
  }
}

/* ==========================================================================
   Shared Buttons & Inputs
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--ink-primary);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition:
    transform var(--duration-fast) var(--ease-spring),
    background-color var(--duration-fast) var(--ease-smooth),
    border-color var(--duration-fast) var(--ease-smooth),
    box-shadow var(--duration-fast) var(--ease-smooth),
    color var(--duration-fast) var(--ease-smooth);
}

.btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(24, 24, 27, 0.14);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-ink-hover);
  border-color: var(--accent-ink-hover);
  box-shadow: 0 4px 16px rgba(24, 24, 27, 0.2);
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-secondary);
}

.btn--ghost:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.05);
  border-color: transparent;
  color: var(--ink-primary);
}

.btn--danger {
  color: var(--accent-rose);
  border-color: rgba(190, 18, 60, 0.2);
  background: var(--accent-rose-soft);
}

.btn--danger:hover:not(:disabled) {
  background: #ffe4e6;
  border-color: rgba(190, 18, 60, 0.35);
}

.btn--sm {
  height: 34px;
  padding: 0 13px;
  font-size: 13px;
}

.btn--icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Subject Color Pills (deterministic soft pastel tags) */
.subject-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.5;
  border: 1px solid transparent;
}

.subject-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.subject-pill--tone-0 { background: #eff6ff; color: #1d4ed8; border-color: rgba(29, 78, 216, 0.1); }
.subject-pill--tone-1 { background: #f0fdf4; color: #15803d; border-color: rgba(21, 128, 61, 0.1); }
.subject-pill--tone-2 { background: #f5f3ff; color: #6d28d9; border-color: rgba(109, 40, 217, 0.1); }
.subject-pill--tone-3 { background: #fffbeb; color: #b45309; border-color: rgba(180, 83, 9, 0.12); }
.subject-pill--tone-4 { background: #fff1f2; color: #be123c; border-color: rgba(190, 18, 60, 0.1); }
.subject-pill--tone-5 { background: #ecfeff; color: #0e7490; border-color: rgba(14, 116, 144, 0.1); }

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-stack {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 420px);
}

.toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  background: rgba(24, 24, 27, 0.94);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(10px);
  animation: toastIn 320ms var(--ease-spring) forwards;
}

.toast--error {
  background: rgba(190, 18, 60, 0.95);
}

.toast--success {
  background: rgba(21, 128, 61, 0.95);
}

.toast.is-leaving {
  animation: toastOut 220ms var(--ease-smooth) forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
}

/* ==========================================================================
   Editorial Markdown Content Styling (Shared by Reader & Admin Live Preview)
   ========================================================================== */

.prose {
  font-size: 15.5px;
  line-height: 1.88;
  color: #272c36;
  word-break: break-word;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  color: var(--ink-primary);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.4;
  margin-top: 1.8em;
  margin-bottom: 0.7em;
}

.prose h1 {
  font-size: 1.45em;
  padding-bottom: 0.45em;
  border-bottom: 1px solid var(--border-hairline);
}

.prose h2 {
  font-size: 1.25em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border-hairline);
}

.prose h3 {
  font-size: 1.08em;
}

.prose p {
  margin: 0.9em 0;
}

.prose strong {
  color: var(--ink-primary);
  font-weight: 650;
}

.prose em {
  color: var(--ink-secondary);
}

.prose a {
  color: var(--accent-blue);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(37, 99, 235, 0.35);
  transition: text-decoration-color var(--duration-fast);
}

.prose a:hover {
  text-decoration-color: var(--accent-blue);
}

.prose ul,
.prose ol {
  margin: 0.9em 0;
  padding-left: 1.5em;
}

.prose li {
  margin: 0.4em 0;
}

.prose li::marker {
  color: var(--ink-muted);
}

.prose hr {
  border: 0;
  height: 1px;
  background: var(--border-hairline);
  margin: 1.8em 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: #f3f4f6;
  color: #1f2937;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.prose .code-block {
  position: relative;
  margin: 1.25em 0;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-hairline);
  overflow: hidden;
}

.prose .code-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border-hairline);
  font-size: 12px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.prose .code-block__copy {
  border: 0;
  background: transparent;
  color: var(--ink-secondary);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background-color var(--duration-fast), color var(--duration-fast);
}

.prose .code-block__copy:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--ink-primary);
}

.prose .code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.65;
}

.prose .code-block pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.prose blockquote {
  margin: 1.2em 0;
  padding: 12px 16px;
  border-left: 3px solid var(--ink-primary);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink-secondary);
}

.prose blockquote p {
  margin: 0.35em 0;
}

/* Callout blocks: > [!TIP], > [!NOTE], > [!WARNING] */
.prose .callout {
  margin: 1.3em 0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hairline);
  background: #f8fafc;
}

.prose .callout__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 6px;
}

.prose .callout__body p {
  margin: 0.25em 0;
  font-size: 14.5px;
}

.prose .callout--tip {
  background: #f0fdf4;
  border-color: rgba(21, 128, 61, 0.15);
}

.prose .callout--tip .callout__title {
  color: var(--accent-green);
}

.prose .callout--note {
  background: #eff6ff;
  border-color: rgba(37, 99, 235, 0.15);
}

.prose .callout--note .callout__title {
  color: var(--accent-blue);
}

.prose .callout--warning {
  background: #fffbeb;
  border-color: rgba(180, 83, 9, 0.18);
}

.prose .callout--warning .callout__title {
  color: var(--accent-amber);
}

/* Tables */
.prose .table-wrap {
  margin: 1.25em 0;
  overflow-x: auto;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.6;
}

.prose th,
.prose td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-hairline);
}

.prose th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--ink-primary);
  white-space: nowrap;
}

.prose tr:last-child td {
  border-bottom: 0;
}

/* ==========================================================================
   Skeleton Loading Shimmer
   ========================================================================== */

.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e9edf2 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   Accessibility: Respect Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
