/**
 * Shared header styles and CSS variables for all Chaturanga pages.
 * Included by rules/ and help/ static pages via <link rel="stylesheet">.
 * The main app (React) embeds these same rules in game.css.
 */

/* Dark is the default — applies when there is no OS preference and no explicit theme pin. */

:root {
  --color-primary: #f0e8d8;
  --color-primary-hover: #d9cfc0;
  --color-secondary: #a09080;
  --color-tertiary: #2a2520;
  --color-tertiary-hover: #332d28;
  --color-border: #3a3228;
  --color-border-light: #342e28;
  --color-surface: #221e1a;
  --color-bg: #1a1612;
  --font-base: 'Roboto', sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --color-primary: #1a1a1a;
    --color-primary-hover: #333;
    --color-secondary: #555;
    --color-tertiary: #f5f5f5;
    --color-tertiary-hover: #e8e8e8;
    --color-border: #e0e0e0;
    --color-border-light: #ddd;
    --color-surface: #fafafa;
    --color-bg: #ffffff;
    color-scheme: light;
  }
}

[data-theme='light'] {
  --color-primary: #1a1a1a;
  --color-primary-hover: #333;
  --color-secondary: #555;
  --color-tertiary: #f5f5f5;
  --color-tertiary-hover: #e8e8e8;
  --color-border: #e0e0e0;
  --color-border-light: #ddd;
  --color-surface: #fafafa;
  --color-bg: #ffffff;
  color-scheme: light;
}

[data-theme='dark'] {
  --color-primary: #f0e8d8;
  --color-primary-hover: #d9cfc0;
  --color-secondary: #a09080;
  --color-tertiary: #2a2520;
  --color-tertiary-hover: #332d28;
  --color-border: #3a3228;
  --color-border-light: #342e28;
  --color-surface: #221e1a;
  --color-bg: #1a1612;
  color-scheme: dark;
}

/* --- Logo dark/light switching --- */

/* Light logo hidden by default (dark is the default theme) */
.app-header__logo--light { display: none; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) .app-header__logo--dark  { display: none; }
  :root:not([data-theme='dark']) .app-header__logo--light { display: block; }
}

[data-theme='light'] .app-header__logo--dark  { display: none; }
[data-theme='light'] .app-header__logo--light { display: block; }
[data-theme='dark']  .app-header__logo--light { display: none; }
[data-theme='dark']  .app-header__logo--dark  { display: block; }

/* --- App header --- */

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  font-family: var(--font-base);
}

.app-header__logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.app-header__logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

/* Mobile: hamburger + dropdown */
.app-header__nav-mobile {
  display: none;
  position: relative;
}

.app-header__menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  background: var(--color-bg);
  cursor: pointer;
  transition: background 0.15s;
  padding: 0;
  color: var(--color-primary);
}

.app-header__menu-btn:hover { background: var(--color-tertiary-hover); }
.app-header__menu-btn--open  { background: var(--color-tertiary); }

.app-header__menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  list-style: none;
  margin: 0;
  padding: 6px;
  z-index: 200;
}

.app-header__menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background 0.1s;
  font-family: var(--font-base);
}

.app-header__menu-item:hover { background: var(--color-tertiary); }

.app-header__menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 12px;
}

/* Desktop: site links */
.app-header__site-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.app-header__site-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-secondary);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  font-family: var(--font-base);
}

.app-header__site-link:hover {
  color: var(--color-primary);
  background: var(--color-tertiary-hover);
}

/* Theme toggle button */
.app-header__theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  background: none;
  color: var(--color-secondary);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.app-header__theme-btn:hover {
  background: var(--color-tertiary-hover);
  color: var(--color-primary);
}

/* Auth row (theme btn lives here, right-aligned) */
.app-header__auth {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Responsive: ≤ 640px — hamburger visible, desktop links hidden */
@media (max-width: 640px) {
  .app-header__nav-mobile  { display: block; }
  .app-header__site-links  { display: none; }
}
