/* =========================================================
   CESIS — Shared stylesheet
   ========================================================= */

/* ===== Theme variables ===== */
:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #161616;
  --border: #1f1f1f;
  --text-primary: #f5f5f5;
  --text-secondary: #888888;
  --text-muted: #555555;
  --accent: #ccdbca;
  --accent-hover: #bbcec2;
  --accent-soft: rgba(204, 219, 202, 0.08);
  --accent-contrast: #0a0a0a; /* text color used ON TOP of --accent (buttons etc.) */
  --score-green: #34d399;
  --score-yellow: #fbbf24;
  --score-orange: #fb923c;
  --score-red: #ef4444;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.1);

  /* Layout tokens — shared by every page so nav/content stay identical */
  --nav-height: 72px;
  --nav-max-width: 1180px;
  --content-max-width: 1080px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 7px;
  --shadow-soft: 0 16px 40px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f1ee;
  --border: #e2e2df;
  --text-primary: #16181a;
  --text-secondary: #5c6066;
  --text-muted: #9297a0;
  --accent: #3f7a56;
  --accent-hover: #336347;
  --accent-soft: rgba(63, 122, 86, 0.08);
  --accent-contrast: #ffffff;
  --score-green: #1f9d6f;
  --score-yellow: #b8860b;
  --score-orange: #c2600f;
  --score-red: #dc2626;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --shadow-soft: 0 16px 40px rgba(20, 20, 20, 0.12);
}

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

/* ===== Base / reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
*,
*::before,
*::after {
  cursor: auto;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

html,
body {
  cursor: none;
}
a,
button,
input,
label,
textarea,
select,
[role="button"] {
  cursor: none;
}

/* Restore normal cursors on touch / no-hover devices — custom cursor has
   no meaning there and previously left the pointer invisible. */
@media (hover: none), (pointer: coarse) {
  html,
  body,
  a,
  button,
  input,
  label,
  textarea,
  select,
  [role="button"] {
    cursor: auto;
  }
  .cursor-dot,
  .cursor-outline {
    display: none;
  }
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
}

a {
  color: inherit;
}
button {
  font-family: inherit;
}

/* Focus visibility for keyboard users — never removed, only restyled */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== Custom cursor ===== */
.cursor-dot,
.cursor-outline {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 9999;
  pointer-events: none;
}
.cursor-dot {
  width: 6px;
  height: 6px;
  background-color: var(--accent);
}
.cursor-outline {
  width: 30px;
  height: 30px;
  border: 1px solid var(--accent);
  transition:
    width 0.2s,
    height 0.2s,
    background-color 0.2s;
}

/* =========================================================
   Background — layered aurora + faint grid texture
   ========================================================= */
.bg-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-grid {
  position: absolute;
  inset: -1px;
  background-image:
    linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.35;
  mask-image: radial-gradient(
    ellipse 80% 60% at 50% 0%,
    #000 40%,
    transparent 90%
  );
  -webkit-mask-image: radial-gradient(
    ellipse 80% 60% at 50% 0%,
    #000 40%,
    transparent 90%
  );
}

/* Wavy Parallax Canvas */
#starCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* =========================================================
   Standardized site header / navbar
   Full-width sticky bar, independent of any page's own content
   width — this is what keeps every page's nav pixel-identical.
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 150;
  height: var(--nav-height);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header-inner {
  max-width: var(--nav-max-width);
  height: 100%;
  margin: 0 auto;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.logo {
  display: inline-flex;
  align-items: center;
}
.logo a {
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 28px;
  align-items: center;
}
.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s ease;
  background: none;
  border: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-link:hover {
  color: var(--accent);
}
.nav-link.active {
  color: var(--accent);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  content: "";
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  position: relative;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}
.nav-toggle span::before {
  position: absolute;
  top: -5px;
}
.nav-toggle span::after {
  position: absolute;
  top: 5px;
}
.nav-toggle[aria-expanded="true"] span {
  background: transparent;
}
.nav-toggle[aria-expanded="true"] span::before {
  transform: translateY(5px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span::after {
  transform: translateY(-5px) rotate(-45deg);
}

@media (max-width: 860px) {
  .site-header-inner {
    padding: 0 20px;
  }
  .nav-toggle {
    display: flex;
  }
  .nav-links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition:
      max-height 0.25s ease,
      opacity 0.2s ease;
  }
  .nav-links.open {
    max-height: 420px;
    opacity: 1;
  }
  .nav-links .nav-link {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    width: 100%;
  }
  .user-menu {
    width: 100%;
  }
  .user-menu-trigger {
    width: 100%;
    padding: 16px 20px;
  }
  .user-menu-dropdown {
    position: static;
    box-shadow: none;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
  }
}

/* ===== CESIS wordmark - signature shimmer ===== */
:root {
  --logo-shine: rgba(255, 255, 255, 0.95);
}

.logo-cesis {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  background-image: linear-gradient(
    100deg,
    var(--accent) 0%,
    var(--accent) 38%,
    var(--logo-shine) 50%,
    var(--accent) 62%,
    var(--accent) 100%
  );
  background-size: 220% 100%;
  background-position: 0% 50%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: logo-shimmer 6s ease-in-out infinite;
  transition:
    animation-duration 0.3s ease,
    filter 0.3s ease;
}
.logo-cesis:hover {
  animation-duration: 2s;
  filter: drop-shadow(0 0 10px var(--accent-soft));
}
@keyframes logo-shimmer {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: -220% 50%;
  }
}
@media (prefers-reduced-motion: reduce) {
  .logo-cesis {
    animation: none;
    background-position: 35% 50%;
  }
  .logo-cesis:hover {
    filter: none;
  }
}
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .logo-cesis {
    color: var(--accent);
    background: none;
    -webkit-text-fill-color: unset;
  }
}

/* ===== Shared page shell ===== */
.page {
  position: relative;
  z-index: 1;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 48px 40px 80px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 40px;
  flex-wrap: wrap;
  gap: 20px;
}
.page-title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 28px var(--accent-soft);
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 6px;
}

@media (max-width: 768px) {
  .page {
    padding: 32px 20px 64px;
  }
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease,
    opacity 0.2s ease;
  font-family: inherit;
  text-decoration: none;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-soft);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  transition:
    border-color 0.2s ease,
    color 0.2s ease;
}
.btn-secondary:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  background: transparent;
  border: 1px solid var(--danger-soft);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}
.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-small {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  font-family: inherit;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-small:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-small.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.btn-small.primary-outline {
  border-color: var(--accent);
  color: var(--accent);
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.4s;
  }
}

/* ===== Cards / surfaces ===== */
.section-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 32px;
  margin-bottom: 24px;
  transition: border-color 0.25s ease;
}
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}
.section-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ===== Forms ===== */
.input-group {
  margin-bottom: 16px;
}
.input-group.full {
  grid-column: 1 / -1;
}
.input-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}
.input-field,
textarea.input-field,
select.input-field {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}
.input-field:focus,
textarea.input-field:focus,
select.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-field::placeholder {
  color: var(--text-muted);
}
textarea.input-field {
  resize: vertical;
  min-height: 80px;
}
.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}
@media (max-width: 640px) {
  .form-grid,
  .form-grid.cols-3 {
    grid-template-columns: 1fr;
  }
}

/* Toggle switch — used across settings for boolean preferences */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.switch-row:last-child {
  border-bottom: none;
}
.switch-label {
  font-size: 14px;
  font-weight: 500;
}
.switch-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.switch-track::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--text-primary);
  border-radius: 50%;
  transition: transform 0.2s ease;
}
.switch input:checked + .switch-track {
  background: var(--accent);
}
.switch input:checked + .switch-track::before {
  transform: translateX(18px);
  background: var(--accent-contrast);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Messages / alerts / toasts ===== */
.msg {
  font-size: 13px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  line-height: 1.5;
}
.msg.success {
  color: var(--accent);
  background: var(--accent-soft);
}
.msg.error {
  color: var(--danger);
  background: var(--danger-soft);
}

.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 0.25s ease;
}
.toast.error {
  border-color: var(--danger-soft);
}
.toast.success {
  border-color: var(--accent-soft);
}
.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
  background: var(--text-muted);
}
.toast.success .toast-dot {
  background: var(--score-green);
}
.toast.error .toast-dot {
  background: var(--danger);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 480px) {
  .toast-stack {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

/* ===== Modal (shared pattern used by dashboard + confirm dialogs) ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open {
  display: flex;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-soft);
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
}
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}
.modal-actions > * {
  flex: 1;
}
.modal-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 16px;
  display: none;
}

/* ===== User dropdown menu ===== */
.user-menu {
  position: relative;
}
.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 2px;
}
.user-menu-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.user-menu-caret {
  font-size: 9px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.user-menu.open .user-menu-caret {
  transform: rotate(180deg);
}
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: var(--shadow-soft);
  z-index: 200;
}
.user-menu.open .user-menu-dropdown {
  display: block;
}
.user-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
}
.user-menu-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.user-menu-item-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ===== Shared footer ===== */
footer {
  margin-top: 100px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 16px;
}
.social-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.3s ease;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.social-link:hover {
  color: var(--accent);
  border-color: var(--border);
  background: var(--accent-soft);
}
.social-link svg {
  transition: transform 0.3s ease;
}
.social-link:hover svg {
  transform: translateY(-1px);
}
