/* ============================================
   ClockTools.com - Shared Design System
   ============================================ */

/* CSS Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2035;
  --bg-card-hover: #1f2847;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #1e293b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3 {
  line-height: 1.2;
  font-weight: 700;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-hover);
}

/* ============================================
   Navigation
   ============================================ */
.nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.nav-logo svg {
  width: 28px;
  height: 28px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  list-style: none;
}

/* Top-level nav items (Home, dropdown triggers) */
.nav-links > a,
.nav-dropdown > .nav-dropdown-trigger {
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.nav-links > a:hover,
.nav-links > a.active,
.nav-dropdown:hover > .nav-dropdown-trigger,
.nav-dropdown > .nav-dropdown-trigger.active {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* Dropdown caret */
.nav-dropdown-trigger .caret {
  font-size: 0.6rem;
  transition: transform 0.2s;
}

.nav-dropdown:hover .nav-dropdown-trigger .caret {
  transform: rotate(180deg);
}

/* Dropdown container */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 200;
}

.nav-dropdown:hover .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
  color: var(--text-primary);
  background: var(--bg-card);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

@media (max-width: 768px) {
  .nav { padding: 0 1rem; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.75rem;
    gap: 0;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }
  .nav-links.open { display: flex; }

  /* On mobile, dropdowns are always expanded */
  .nav-dropdown { width: 100%; }
  .nav-dropdown-trigger .caret { display: none; }
  .nav-dropdown-menu {
    display: block;
    position: static;
    border: none;
    box-shadow: none;
    padding: 0 0 0.5rem 0.75rem;
    min-width: 0;
  }
  .nav-dropdown > .nav-dropdown-trigger {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.75rem 0.5rem 0.25rem;
    cursor: default;
  }
  .nav-dropdown > .nav-dropdown-trigger:hover {
    background: none;
  }
  .nav-dropdown-menu a {
    padding: 0.5rem 0.75rem;
    width: 100%;
  }
  .nav-links > a {
    padding: 0.5rem 0.75rem;
    width: 100%;
  }
}

/* ============================================
   Main Content
   ============================================ */
.main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

@media (max-width: 768px) {
  .main { padding: 1rem; }
}

/* Page Header */
.page-header {
  text-align: center;
  margin-bottom: 2rem;
}

.page-header h1 {
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ============================================
   Cards & Containers
   ============================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  transition: all 0.2s;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #16a34a;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-warning {
  background: var(--warning);
  color: #1a1a1a;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

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

.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============================================
   Timer Display (shared across timer pages)
   ============================================ */
.timer-display {
  font-family: var(--font-mono);
  font-size: 6rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.05em;
  padding: 2rem 0;
  color: var(--text-primary);
  text-shadow: 0 0 40px var(--accent-glow);
  user-select: none;
}

@media (max-width: 768px) {
  .timer-display { font-size: 3.5rem; }
}

@media (max-width: 480px) {
  .timer-display { font-size: 2.5rem; }
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s linear, background-color 0.5s;
}

.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }

/* ============================================
   Input Elements
   ============================================ */
.input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-sans);
  width: 100%;
  transition: border-color 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.input-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.time-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}

.time-input {
  width: 100px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
}

.time-separator {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ============================================
   Fullscreen Mode
   ============================================ */
.fullscreen-btn {
  position: fixed;
  top: 80px;
  right: 1rem;
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.1rem;
}

.fullscreen-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

body.is-fullscreen .nav,
body.is-fullscreen .page-header,
body.is-fullscreen .footer,
body.is-fullscreen .seo-content {
  display: none !important;
}

body.is-fullscreen .main {
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

body.is-fullscreen .timer-display {
  font-size: 12rem;
}

body.is-fullscreen .fullscreen-btn {
  top: 1rem;
}

@media (max-width: 768px) {
  body.is-fullscreen .timer-display { font-size: 5rem; }
}

/* ============================================
   Footer
   ============================================ */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 3rem 2rem 2rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.footer-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-group h4 {
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.footer-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-group ul li {
  margin-bottom: 0.4rem;
}

.footer-group ul li a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer-group ul li a:hover {
  color: var(--text-primary);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-bottom a {
  color: var(--text-muted);
}

.footer-bottom a:hover {
  color: var(--text-primary);
}

/* Legacy flat footer support */
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.footer-links a:hover {
  color: var(--text-primary);
}

@media (max-width: 600px) {
  .footer-groups {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

/* ============================================
   SEO Content Section
   ============================================ */
.seo-content {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.seo-content h2 {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.seo-content p {
  margin-bottom: 1rem;
}

/* ============================================
   Utilities
   ============================================ */
.text-center { text-align: center; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.hidden { display: none !important; }

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-pulse { animation: pulse 2s infinite; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

.fade-in { animation: fadeIn 0.3s ease-out; }

/* ============================================
   Related Tools Section
   ============================================ */
.related-tools {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.related-tools h2 {
  text-align: center;
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.related-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.related-tool-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.2s;
  font-weight: 500;
  font-size: 0.95rem;
}

.related-tool-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  box-shadow: 0 0 15px var(--accent-glow);
  color: var(--text-primary);
}

.related-tool-card span.icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* ============================================
   Keyboard Shortcuts Help
   ============================================ */
.shortcuts-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 1rem;
}

.shortcuts-hint kbd {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0 0.1rem;
}

/* ============================================
   Breadcrumb
   ============================================ */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  text-align: center;
}

.breadcrumb a {
  color: var(--text-secondary);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb .sep {
  margin: 0 0.4rem;
  color: var(--text-muted);
}

/* ============================================
   Light Mode
   ============================================ */
body.light-mode {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.15);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

body.light-mode .nav {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body.light-mode .card:hover {
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.12);
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  body {
    background: white !important;
    color: black !important;
  }

  .nav, .footer, .fullscreen-btn, .theme-toggle,
  .btn-group, .shortcuts-hint, .related-tools {
    display: none !important;
  }

  .main {
    max-width: 100%;
    padding: 0;
  }

  .timer-display {
    color: black !important;
    text-shadow: none !important;
    font-size: 4rem !important;
  }

  .card, .seo-content {
    background: white !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }

  .seo-content {
    color: #333 !important;
  }

  .seo-content h2 {
    color: #111 !important;
  }

  a { color: black !important; text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}
