/**
 * DOLY Studio — Base Layout CSS
 * 모든 서비스에서 공유. <link rel="stylesheet" href="/shared/css/base.css">로 로드.
 * 서비스별 style.css에서 디자인시스템 색상/폰트를 오버라이드한다.
 */

/* ============================================================
   CSS Variables (기본값 — 서비스별 style.css에서 오버라이드)
   ============================================================ */
:root {
  /* Surface — Cinema Dark (no pure #000, OLED-friendly) */
  --bg: #050506;
  --bg-elevated: #0a0a0c;
  --bg-card: #0f0f12;
  --bg-hover: #16161a;
  --bg-surface: rgba(255,255,255,0.03);

  /* Borders — subtle hairline */
  --border: rgba(255,255,255,0.08);
  --border-subtle: rgba(255,255,255,0.05);
  --border-focus: rgba(94,106,210,0.5);

  /* Text — high contrast on dark */
  --text-muted: #4a4a5a;
  --text-secondary: #8a8f98;
  --text-primary: #ededef;

  /* Accent — overridable per service */
  --accent: #5e6ad2;
  --accent-hover: #6e7ae2;
  --accent-soft: rgba(94,106,210,0.12);
  --accent-glow: rgba(94,106,210,0.2);

  /* Semantic */
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --info: #3b82f6;

  /* Layout */
  --header-height: 56px;
  --sidebar-width: 200px;
  --card-radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 9999px;

  /* Motion — Cinema easing */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-normal: 250ms var(--ease-out);
  --transition-slow: 400ms var(--ease-out);

  /* Shadows — layered depth */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 24px var(--accent-glow);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-hover); }
::selection { background: var(--accent-soft); color: var(--text-primary); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   Global Header
   ============================================================ */
.global-header {
  background: rgba(5,5,6,0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-normal);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.logo {
  color: var(--accent); font-weight: 800; font-size: 20px;
  text-decoration: none; letter-spacing: -0.3px;
  transition: opacity var(--transition-fast);
}
.logo:hover { opacity: 0.85; color: var(--accent); }
.breadcrumb { color: var(--text-secondary); font-size: 13px; }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--text-primary); }
.sep { margin: 0 6px; opacity: 0.5; }
.back-to-hub {
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: 8px;
  transition: all var(--transition-fast);
}
.back-to-hub:hover { color: var(--text-primary); background: var(--bg-hover); }

/* Theme Toggle */
.theme-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 18px;
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition-fast);
}
.theme-toggle:hover { color: var(--text-primary); background: var(--bg-hover); }
.theme-toggle:active { transform: scale(0.92); }

/* ============================================================
   3-Column Layout
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width);
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
}
.sidebar { position: sticky; top: calc(var(--header-height) + 24px); align-self: start; }
.main-content { min-width: 0; }

/* ============================================================
   Ad Slots
   ============================================================ */
.ad-slot {
  display: flex; justify-content: center; align-items: center;
  background: var(--bg-card);
  border-radius: var(--card-radius);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}
.ad-slot--inline { margin: 28px 0; }
.ad-slot--bottom { margin: 28px 0 0; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal), transform var(--transition-normal);
}
.card:hover {
  border-color: rgba(255,255,255,0.12);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-title {
  font-size: 17px; font-weight: 700; margin-bottom: 16px;
  letter-spacing: -0.2px;
}

/* ============================================================
   Hero Section
   ============================================================ */
.hero-section { margin-bottom: 28px; }
.hero-section h1 {
  font-size: 36px; font-weight: 800; margin-bottom: 10px;
  letter-spacing: -0.8px;
  color: var(--text-primary);
  text-shadow: 0 0 40px var(--accent-glow);
}
.subtitle {
  color: var(--text-secondary); font-size: 16px;
  max-width: 600px; line-height: 1.7;
}

/* ============================================================
   Auth UI
   ============================================================ */
.controls-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.btn-login {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 20px; font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}
.btn-login:hover { background: var(--bg-hover); border-color: var(--text-muted); box-shadow: var(--shadow-md); }
.btn-login:active { transform: scale(0.97); }
.btn-login img { flex-shrink: 0; }
.user-info {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--text-secondary); font-weight: 500;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--border); object-fit: cover;
}
.btn-logout {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 13px; margin-left: 8px;
  transition: color var(--transition-fast);
}
.btn-logout:hover { color: var(--danger); }

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 12px 28px; font-weight: 600; font-size: 14px;
  cursor: pointer; letter-spacing: 0.2px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm), var(--shadow-glow);
  position: relative; overflow: hidden;
}
.btn-primary::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  opacity: 0; transition: opacity var(--transition-fast);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md), 0 0 32px var(--accent-glow);
  transform: translateY(-2px);
}
.btn-primary:hover::after { opacity: 1; }
.btn-primary:active { transform: translateY(0) scale(0.97); }
.btn-primary:disabled {
  opacity: 0.4; cursor: not-allowed;
  transform: none; box-shadow: none;
}

.btn-secondary {
  background: transparent; color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 28px; font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-secondary:active { transform: scale(0.97); }

.btn-text {
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 14px; font-weight: 500; padding: 6px 2px;
  transition: color var(--transition-fast);
  position: relative;
}
.btn-text:hover { color: var(--text-primary); }
.btn-text::after {
  content: ''; position: absolute; bottom: 2px; left: 0; right: 0;
  height: 1px; background: currentColor; opacity: 0;
  transition: opacity var(--transition-fast);
}
.btn-text:hover::after { opacity: 0.4; }

/* ============================================================
   Form Elements
   ============================================================ */
input[type="text"], input[type="number"], input[type="email"],
input[type="date"], input[type="tel"], input[type="url"],
textarea, select {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 16px var(--accent-glow);
  outline: none;
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}
label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 6px;
  letter-spacing: 0.3px; text-transform: uppercase;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper { overflow-x: auto; border-radius: var(--card-radius); }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 12px 16px;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
td {
  padding: 12px 16px; font-size: 14px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
tr:hover td { background: var(--bg-hover); }
.table-empty { text-align: center; color: var(--text-muted); padding: 32px 16px; }

/* ============================================================
   Progress Bar
   ============================================================ */
.progress-bar-container {
  width: 100%; height: 8px;
  background: var(--bg-hover); border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width var(--transition-slow);
}

/* ============================================================
   Stats Grid
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius); padding: 16px;
  text-align: center;
  transition: all var(--transition-fast);
}
.stat-card:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }
.stat-label {
  display: block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 6px;
}
.stat-value {
  display: block; font-size: 22px; font-weight: 800;
  color: var(--text-primary); letter-spacing: -0.5px;
}

/* ============================================================
   Cross-Links
   ============================================================ */
.cross-links {
  padding: 36px 0; border-top: 1px solid var(--border-subtle); margin-top: 36px;
}
.cross-links h2 {
  font-size: 22px; font-weight: 700; margin-bottom: 20px;
  letter-spacing: -0.3px;
}
.cross-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.cross-link-card {
  background: var(--bg-card); border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius); padding: 20px;
  text-decoration: none; color: var(--text-primary);
  transition: all var(--transition-normal);
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--shadow-sm);
}
.cross-link-card:hover {
  background: var(--bg-hover); border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.cross-link-icon { font-size: 28px; margin-bottom: 4px; }
.cross-link-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.cross-link-desc { color: var(--text-secondary); font-size: 13px; line-height: 1.5; }

/* ============================================================
   Educational Content
   ============================================================ */
.content-section { margin-top: 40px; }
.content-section h2 {
  font-size: 22px; font-weight: 700; margin: 36px 0 14px;
  letter-spacing: -0.3px;
}
.content-section p {
  color: var(--text-secondary); font-size: 15px;
  line-height: 1.85; margin-bottom: 14px;
}
.content-section ul { padding-left: 20px; margin-bottom: 16px; }
.content-section li {
  color: var(--text-secondary); font-size: 15px;
  line-height: 1.85; margin-bottom: 8px;
}
.content-section a { text-decoration: underline; text-underline-offset: 3px; }

/* FAQ */
.faq-section details {
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius); margin-bottom: 10px;
  transition: all var(--transition-fast);
}
.faq-section details:hover { border-color: var(--border); }
.faq-section details[open] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft); }
.faq-section summary {
  padding: 16px 20px; cursor: pointer; font-weight: 600; font-size: 15px;
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  transition: color var(--transition-fast);
}
.faq-section summary:hover { color: var(--accent); }
.faq-section summary::after {
  content: '+'; font-size: 20px; color: var(--text-muted);
  transition: transform var(--transition-fast), color var(--transition-fast);
}
.faq-section details[open] summary::after { content: '−'; color: var(--accent); }
.faq-answer { padding: 0 20px 18px; }
.faq-answer p { margin-bottom: 8px; }

/* ============================================================
   Global Footer
   ============================================================ */
.global-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 40px 32px; text-align: center;
  color: var(--text-muted); font-size: 13px;
  margin-top: 48px;
}
.footer-links { margin-bottom: 12px; }
.footer-links a {
  color: var(--text-secondary); margin: 0 16px;
  transition: color var(--transition-fast);
}
.footer-links a:hover { color: var(--text-primary); }
.footer-copyright { opacity: 0.6; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn var(--transition-fast) ease-out;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; max-width: 420px; width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp var(--transition-normal) ease-out;
}
.modal h3 { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.modal p { color: var(--text-secondary); font-size: 15px; margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--accent);
  padding: 14px 28px; border-radius: 12px;
  font-weight: 600; font-size: 14px;
  z-index: 300; opacity: 0;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  pointer-events: none;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   Loading Spinner
   ============================================================ */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
.spinner--lg { width: 40px; height: 40px; border-width: 4px; }

/* ============================================================
   Skeleton Loading
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--card-radius);
}

/* ============================================================
   Badges / Tags
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--warning { background: rgba(245,197,24,0.12); color: var(--warning); }
.badge--danger { background: rgba(229,62,62,0.12); color: var(--danger); }
.badge--success { background: rgba(56,161,105,0.12); color: var(--success); }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ============================================================
   Utility Classes
   ============================================================ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.fade-in { animation: fadeIn var(--transition-normal) ease-out; }
.slide-up { animation: slideUp var(--transition-normal) ease-out; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr var(--sidebar-width); }
  .sidebar--left { display: none; }
}
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .sidebar { display: none; }
  .global-header { padding: 0 16px; height: 56px; }
  .breadcrumb { display: none; }
  .hero-section h1 { font-size: 26px; }
  .cross-links-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .card { padding: 18px; }
}
@media (max-width: 480px) {
  .cross-links-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
