/* ==========================================================================
   DirencHan — "Oceanic" Design System
   Deep layered navy + cyan/turquoise glow, inspired by the Ocean Anti-Cheat
   (anticheat.ac) brand identity, adapted for a precision electronics-calculator
   product. Single locked dark theme — no theme picker (see includes/header.php
   for why: the old picker only ever worked in dark mode anyway).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* ---- Layered navy surfaces (depth, not flat black) ---- */
  --bg-deep:      #050B14;   /* page background */
  --bg-panel:     #0A1628;   /* cards, sidebar */
  --bg-elevated:  #0F2138;   /* hover / active surfaces */
  --bg-input:     #0B1A2C;

  /* ---- Cyan / turquoise glow family ---- */
  --primary:      #22D3EE;   /* signature glow */
  --primary-dim:  #0EA5B7;   /* pressed / secondary */
  --accent2:      #2DD4BF;   /* secondary highlight, success */
  --primary-glow: rgba(34, 211, 238, 0.35);

  /* ---- Utility (used sparingly, not part of the signature palette) ---- */
  --danger:  #F43F5E;
  --danger-dim: rgba(244, 63, 94, 0.12);
  --warning: #FBBF24;
  --success: #2DD4BF;

  /* ---- Text ---- */
  --text-primary:   #E8F1F8;
  --text-secondary: #8DA3B8;
  --text-tertiary:  #55697D;

  /* ---- Borders ---- */
  --border:       rgba(34, 211, 238, 0.12);
  --border-hover: rgba(34, 211, 238, 0.30);
  --border-focus: rgba(34, 211, 238, 0.55);

  /* ---- Type ---- */
  --font-display: 'Space Grotesk', 'Inter', -apple-system, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* ---- Motion ---- */
  --t-fast: 0.15s cubic-bezier(0.4,0,0.2,1);
  --t-med:  0.3s cubic-bezier(0.4,0,0.2,1);

  /* ---- Layout ---- */
  --sidebar-w: 264px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shell-max: 1180px;
}

/* ==========================================================================
   Reset & base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html {
  /* Fluid root size prevents the old fixed-px breakpoints from ever
     overflowing at odd zoom levels — this, not a viewport lock, is what
     actually fixes "zooming breaks the layout and can't be reset". */
  font-size: clamp(15px, 0.9vw + 11px, 17px);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@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; }
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: hidden; /* belt-and-braces against any stray wide child forcing horizontal scroll on zoom */
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3.1rem); font-weight: 700; }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem); }
h3 { font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem); }
p { margin: 0 0 1em; color: var(--text-secondary); }
code, .mono { font-family: var(--font-mono); }

/* Visible keyboard focus everywhere — accessibility quality floor */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--primary-glow); color: var(--text-primary); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 8px; border: 2px solid var(--bg-deep); }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ==========================================================================
   Shell layout — sidebar + main + sticky footer
   ========================================================================== */
.app-shell {
  display: flex;
  flex: 1 0 auto;
  width: 100%;
  align-items: stretch;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(5, 11, 20, 0.85);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 34px; width: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-tagline { font-size: 0.72rem; color: var(--text-tertiary); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 18px 12px 90px;
  overflow-y: auto;
  position: sticky;
  top: 63px;
  align-self: flex-start;
  max-height: calc(100dvh - 63px);
}
.sidebar-group { margin-bottom: 6px; }
.sidebar-group-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 16px 12px 6px;
}
/* Explicit visual separation between core navigation and account/system items */
.sidebar-divider {
  height: 1px;
  margin: 14px 8px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.sidebar-account-block {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.nav-item svg { flex: 0 0 auto; opacity: 0.85; }
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: rgba(34,211,238,0.10); color: var(--primary); }
.nav-item.active svg { opacity: 1; }

.nav-group-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: none; border: none; cursor: pointer;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.82rem; font-weight: 600;
}
.nav-group-toggle:hover { color: var(--text-primary); }
.nav-group-toggle .chev { transition: transform var(--t-fast); opacity: 0.6; }
.nav-group.open .nav-group-toggle .chev { transform: rotate(90deg); }
.nav-group-items { display: none; padding-left: 4px; }
.nav-group.open .nav-group-items { display: block; }

.main-content {
  flex: 1 1 0%;
  min-width: 0;
  padding: 40px clamp(16px, 4vw, 48px) 64px;
}
.shell-max { max-width: var(--shell-max); margin: 0 auto; }

/* Mobile sidebar */
.mobile-menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; color: var(--text-primary); cursor: pointer; }
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    max-height: 100dvh;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform var(--t-med);
    box-shadow: 20px 0 60px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; }
  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0; z-index: 55;
    background: rgba(2,6,12,0.6);
    opacity: 0; pointer-events: none;
    transition: opacity var(--t-med);
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  .main-content { padding: 28px 16px 48px; }
}

/* ==========================================================================
   Cards, buttons, inputs, badges
   ========================================================================== */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}
.card-glow {
  position: relative;
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel)) padding-box,
              linear-gradient(135deg, var(--primary), transparent 60%) border-box;
  border: 1px solid transparent;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-weight: 600; font-size: 0.9rem;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), opacity var(--t-fast);
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  color: #001318;
  box-shadow: 0 0 0 rgba(34,211,238,0);
}
.btn-primary:hover { box-shadow: 0 6px 24px -6px var(--primary-glow); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); }
.btn-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(244,63,94,0.3); }
.btn-danger:hover { background: rgba(244,63,94,0.2); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-elevated); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon { padding: 9px; }

.input-wrapper { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.input-wrapper label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.input, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-primary);
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.12);
}
.input::placeholder, input::placeholder { color: var(--text-tertiary); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 0.72rem; font-weight: 600;
  background: rgba(45,212,191,0.12); color: var(--accent2);
  border: 1px solid rgba(45,212,191,0.25);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.result-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-family: var(--font-mono);
  color: var(--primary);
  font-size: 1.05rem;
  min-height: 52px;
  display: flex;
  align-items: center;
  transition: border-color var(--t-fast);
}
.result-box.has-result { border-color: var(--border-hover); }

.divider { height: 1px; background: var(--border); margin: 28px 0; border: none; }

/* ==========================================================================
   Hero — the calculator itself is the thesis, not a generic stat block
   ========================================================================== */
.home-hero {
  position: relative;
  padding: 56px 0 64px;
  overflow: hidden;
}
/* Signature element: a slow sonar-style sweep, evoking both "Ocean" and an
   oscilloscope trace. CSS-only, cheap, respects prefers-reduced-motion. */
.home-hero::before {
  content: '';
  position: absolute;
  left: -10%; right: -10%; height: 140px;
  background: linear-gradient(180deg, transparent, rgba(34,211,238,0.08), transparent);
  animation: sonarSweep 9s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sonarSweep {
  0%   { top: -140px; opacity: 0; }
  10%  { opacity: 1; }
  50%  { top: 50%; opacity: 0.7; }
  90%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .home-hero::before { display: none; }
}
.home-hero h1 {
  background: linear-gradient(135deg, var(--text-primary) 40%, var(--primary));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  /* Plain gradient text, rendered once, server-side language string —
     no word-by-word JS animation. This is the actual fix for the bug where
     the title stayed invisible until a language toggle: that old effect
     wrapped every word in an opacity:0 span and queued a 100ms fade-in that
     could get starved behind heavier scripts on first paint. */
}
.hero-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px; align-items: center; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } }
.hero-stats { display: flex; gap: 28px; margin-top: 24px; flex-wrap: wrap; }
.hero-stat-num { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.hero-stat-label { font-size: 0.78rem; color: var(--text-secondary); }
.hero-quickcalc { animation: fadeSlideIn 0.6s var(--t-med) both; animation-delay: 0.1s; }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Generic entrance animation for section content — CSS only, cannot race */
.reveal-in { animation: fadeSlideIn 0.5s var(--t-med) both; }

/* ==========================================================================
   Calculator grid (homepage + category pages)
   ========================================================================== */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.calc-tile {
  display: block;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color var(--t-fast), transform var(--t-fast), background var(--t-fast);
}
.calc-tile:hover { border-color: var(--border-hover); background: var(--bg-elevated); transform: translateY(-2px); }
.calc-tile h4 { margin: 10px 0 4px; font-size: 0.98rem; }
.calc-tile p { font-size: 0.82rem; margin: 0; }
.calc-tile-icon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 9px; background: rgba(34,211,238,0.10); color: var(--primary); }

/* "Why Choose" section */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; margin-top: 32px; }
.feature-item { display: flex; flex-direction: column; gap: 10px; }
.feature-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); color: var(--primary); }

/* ==========================================================================
   Auth pages — perfectly centered, sticky footer regardless of content height
   ========================================================================== */
.auth-shell {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  min-height: calc(100dvh - 63px);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 24px; background: var(--bg-input); padding: 4px; border-radius: var(--radius-sm); }
.auth-tab { flex: 1; text-align: center; padding: 9px; border-radius: 6px; font-weight: 600; font-size: 0.86rem; color: var(--text-secondary); cursor: pointer; }
.auth-tab.active { background: var(--bg-elevated); color: var(--text-primary); }

/* ==========================================================================
   Footer — flex-based sticky footer (no JS, no fixed heights to fight with)
   ========================================================================== */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 48px clamp(16px,4vw,48px) 24px;
}
.footer-grid { max-width: var(--shell-max); margin: 0 auto; display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; }
@media (max-width: 800px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-col h5 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary); margin-bottom: 14px; }
.footer-col a { display: block; font-size: 0.86rem; color: var(--text-secondary); padding: 5px 0; }
.footer-col a:hover { color: var(--primary); }
.footer-bottom { max-width: var(--shell-max); margin: 32px auto 0; padding-top: 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-size: 0.78rem; color: var(--text-tertiary); }

/* ==========================================================================
   Legal / long-form content pages
   ========================================================================== */
.prose { max-width: 760px; }
.prose h2 { margin-top: 2em; padding-bottom: 0.4em; border-bottom: 1px solid var(--border); }
.prose h3 { margin-top: 1.6em; color: var(--primary); }
.prose ul, .prose ol { color: var(--text-secondary); padding-left: 1.3em; }
.prose li { margin-bottom: 0.5em; }
.prose strong { color: var(--text-primary); }

/* ==========================================================================
   Utility
   ========================================================================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated); border: 1px solid var(--border-hover);
  padding: 12px 20px; border-radius: var(--radius-sm);
  opacity: 0; pointer-events: none; transition: all var(--t-med);
  z-index: 200; font-size: 0.88rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

.scroll-top {
  position: fixed; bottom: 24px; right: 24px; z-index: 50;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-elevated); border: 1px solid var(--border-hover);
  color: var(--primary); display: flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; pointer-events: none; transform: translateY(10px);
  transition: all var(--t-med);
}
.scroll-top.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
