/* ==========================================================================
   KIRITA.ME DESIGN SYSTEM
   Responsive, Elegant, Minimal — Desktop & Mobile
   ========================================================================== */

:root {
  /* === Editorial palette (matches public.css) === */
  --primary: #FF4D1F;            /* signal orange accent */
  --primary-hover: #e63f10;
  --primary-light: rgba(255, 77, 31, 0.12);
  --accent: #FF4D1F;

  --ink: #0a0a0a;
  --ink-2: #2a2a2a;
  --ink-3: #6a6a6a;
  --ink-4: #9a9a9a;

  /* Light Mode — paper warm */
  --bg-color: #f6f4ef;
  --bg-alt: #fbfaf6;
  --bg: var(--bg-color);
  --paper: var(--bg-alt);
  --panel-bg: var(--bg-alt);
  --panel-border: rgba(10, 10, 10, 0.12);
  --rule: rgba(10, 10, 10, 0.12);
  --rule-strong: rgba(10, 10, 10, 0.22);
  --hover: rgba(10, 10, 10, 0.04);

  --text-main: var(--ink);
  --text: var(--ink);
  --text-muted: var(--ink-3);
  --text-light: var(--ink-4);

  /* Card shadows — eliminated for editorial flat look */
  --card-shadow: none;
  --card-shadow-hover: 0 0 0 1px var(--rule-strong);
  --glass-shadow: none;

  /* Spacing & Shape — sharp / editorial */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-round: 999px;
  --transition: all 0.18s ease;
  --transition-bounce: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Typography */
  --font-heading: "Noto Serif Thai", "IBM Plex Serif", serif;
  --font-head: var(--font-heading);
  --font-body: "IBM Plex Sans Thai Looped", "IBM Plex Sans Thai", "Sarabun", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-size-adjust: 100%;

  /* Layout */
  --content-max: 780px;
  --sidebar-width: 280px;
  --nav-height: 64px;
}

[data-theme="dark"] {
  --bg-color: #0c0c0d;
  --bg-alt: #131314;
  --bg: var(--bg-color);
  --paper: var(--bg-alt);
  --panel-bg: var(--bg-alt);
  --panel-border: rgba(255, 255, 255, 0.12);
  --rule: rgba(255, 255, 255, 0.12);
  --rule-strong: rgba(255, 255, 255, 0.22);
  --hover: rgba(255, 255, 255, 0.04);

  --ink: #f1efe8;
  --ink-2: #d3d1c9;
  --ink-3: #8a8a86;
  --ink-4: #5c5c58;

  --text-main: var(--ink);
  --text: var(--ink);
  --text-muted: var(--ink-3);
  --text-light: var(--ink-4);

  --primary-light: rgba(255, 77, 31, 0.15);
  --card-shadow: none;
  --card-shadow-hover: 0 0 0 1px var(--rule-strong);
  --glass-shadow: none;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: var(--font-size-adjust);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.35s ease, color 0.35s ease;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

p { margin-bottom: 1.2rem; font-size: 1.05rem; }

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; height: auto; display: block; }

input, button, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* === TOP NAVIGATION === */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--panel-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--panel-border);
  box-shadow: var(--glass-shadow);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.site-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-logo {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 500;
  font-style: italic;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

.nav-link {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius-round);
  transition: var(--transition);
  text-decoration: none;
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-spacer { flex: 1; }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-settings-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-round);
  background: var(--bg-alt);
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.2rem;
  transition: var(--transition-bounce);
  flex-shrink: 0;
}

.nav-settings-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: rotate(15deg);
}

/* Mobile hamburger */
.nav-hamburger {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-border);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}

/* Mobile nav drawer */
.mobile-nav-drawer {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--panel-border);
  padding: 12px 24px 20px;
  z-index: 999;
  flex-direction: column;
  gap: 4px;
  transform: translateY(-110%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-nav-drawer.open {
  transform: translateY(0);
  display: flex;
}

.mobile-nav-link {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: var(--transition);
}

.mobile-nav-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

/* === GLOBAL LAYOUT === */
.page-wrapper {
  padding-top: var(--nav-height);
  min-height: 100vh;
}

/* === LOADING INDICATOR === */
#loading-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary), #a78bfa, transparent);
  background-size: 200% 100%;
  animation: loading-bar 1.2s infinite linear;
  z-index: 9999;
  display: none;
}

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

/* === BUTTONS — editorial flat === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
[data-theme="dark"] .btn-primary:hover { color: #0c0c0d; }

.btn-secondary {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--rule-strong);
}
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }

/* === ANIMATIONS === */
.fade-in { animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.slide-up { animation: slideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: var(--panel-bg);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  box-shadow: var(--card-shadow-hover);
  backdrop-filter: blur(12px);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  opacity: 0;
  transform: translateY(-12px);
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left: 4px solid #ef4444; }
.toast.success { border-left: 4px solid #10b981; }
.toast.info { border-left: 4px solid var(--primary); }

/* === RESPONSIVE BREAKPOINTS === */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-hamburger { display: flex; }
  :root { --nav-height: 58px; }
}
