/* ═══════════════════════════════════════════════════════
   GamifyMap — Application Styles
   Dark fantasy cartography aesthetic
   ═══════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
  --gm-bg-dark: #0d1117;
  --gm-bg-panel: #161b22;
  --gm-bg-panel-alt: #fce8f0;
  --gm-border: #30363d;
  --gm-accent: #c9a227;
  --gm-accent-dim: #8b7019;
  --gm-text: #e6edf3;
  --gm-text-muted: #b0bac4;
  --gm-success: #3fb950;
  --gm-danger: #f85149;
  --gm-overlay-bg: rgba(13, 17, 23, 0.95);
  --gm-font-display: 'Cinzel', 'Palatino Linotype', serif;
  --gm-font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --gm-font-mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

/* ── Skip Navigation Link (WCAG 2.4.1) ── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 12px;
  z-index: 1000;
  padding: 8px 16px;
  background: var(--gm-accent);
  color: var(--gm-bg-dark);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  border-radius: 0 0 6px 6px;
}

.skip-link:focus {
  top: 0;
}

/* ── Global Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--gm-font-body);
  background: var(--gm-bg-dark);
  color: var(--gm-text);
}

/* ── Calcite Shell Customization ── */
calcite-shell {
  --calcite-color-brand: var(--gm-accent);
  --calcite-color-brand-hover: var(--gm-accent-dim);
}

calcite-navigation {
  --calcite-color-foreground-1: var(--gm-bg-panel);
  border-bottom: 1px solid var(--gm-border);
}

calcite-navigation-logo {
  --calcite-color-text-1: #ffffff;
  --calcite-color-text-2: #ffffff;
  --calcite-color-text-3: #ffffff;
  --calcite-navigation-logo-text-color: #ffffff;
  --calcite-font-size--1: 0.8rem;
  pointer-events: none;
}

/* ── Navigation Header Actions — white icons/text for high contrast (WCAG 1.4.3) ── */
/* White on #161b22 (bg-panel) = 18.8:1 contrast, far exceeds AAA threshold.
   Hover shifts background slightly; text stays white so contrast remains ≥13:1. */
calcite-navigation calcite-action-bar {
  --calcite-color-foreground-1: transparent;
  --calcite-color-text-1: #ffffff;
  --calcite-color-text-2: var(--gm-text-muted);
  --calcite-color-foreground-2: rgba(255, 255, 255, 0.1);
  --calcite-color-foreground-3: rgba(201, 162, 39, 0.22);
}

/* ── Map Container ── */
#viewDiv {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Override ArcGIS widget styles for dark theme */
.esri-ui-corner .esri-component {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

/* ── Panel Content Padding ── */
.panel-content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-content calcite-label {
  margin-bottom: 2px;
}

.panel-content calcite-block {
  margin: 4px 0;
}

/* ── Alternating step shading ── */
.panel-content calcite-block:nth-child(even) {
  --calcite-color-foreground-1: var(--gm-bg-panel-alt);
  --calcite-color-text-1: #2a0e1a;
  --calcite-color-text-2: #4a1e2e;
  --calcite-color-text-3: #6a3048;
}

/* ── Generate Button — bottom of panel ── */
#btn-run-generate {
  margin-top: 4px;
}

/* ── Palette Preview Swatches ── */
.palette-preview {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  padding: 8px;
  background: var(--gm-bg-dark);
  border-radius: 8px;
  border: 1px solid var(--gm-border);
  min-height: 36px;
}

.palette-swatch {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: default;
  position: relative;
}

.palette-swatch:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.4);
  z-index: 1;
}

.palette-swatch::after {
  content: attr(data-label);
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--gm-text-muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.palette-swatch:hover::after {
  opacity: 1;
}

/* ── Hex Map Overlay ── */
.hex-overlay {
  position: absolute;
  top: 80px;
  right: 20px;
  width: 600px;
  max-width: calc(100vw - 400px);
  background: var(--gm-overlay-bg);
  border: 1px solid var(--gm-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(12px);
  resize: both;
  min-width: 320px;
  min-height: 280px;
}

.hex-overlay[hidden] {
  display: none;
}

.hex-overlay.fullscreen {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100% !important;
  max-width: 100%;
  height: 100% !important;
  border-radius: 0;
  resize: none;
  z-index: 500;
}

.hex-overlay.docked {
  top: 56px;
  right: 0;
  bottom: 0;
  width: 50%;
  max-width: 50%;
  height: auto;
  border-radius: 0;
  resize: horizontal;
}

.hex-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(22, 27, 34, 0.8);
  border-bottom: 1px solid var(--gm-border);
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.hex-overlay-header span {
  font-family: var(--gm-font-display);
  font-size: 14px;
  color: var(--gm-accent);
  letter-spacing: 0.5px;
}

.hex-overlay-actions {
  display: flex;
  gap: 2px;
}

.hex-overlay canvas {
  flex: 1;
  width: 100%;
  cursor: grab;
  image-rendering: auto;
  transform-origin: 0 0;
  user-select: none;
}

.hex-overlay canvas.panning {
  cursor: grabbing;
}

.hex-overlay-legend {
  padding: 8px 12px;
  background: rgba(22, 27, 34, 0.8);
  border-top: 1px solid var(--gm-border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--gm-text-muted);
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.15);
  flex-shrink: 0;
}

/* ── Footer Bar ── */
.footer-bar {
  display: flex;
  gap: 8px;
  padding: 4px 12px;
  align-items: center;
  width: 100%;
  background: var(--gm-bg-panel);
  border-top: 1px solid var(--gm-border);
}

.footer-bar calcite-chip {
  --calcite-color-foreground-1: transparent;
  --calcite-color-text-1: var(--gm-text-muted);
  font-family: var(--gm-font-mono);
  font-size: 11px;
}

/* ── Action Active State ── */
calcite-action.action-active {
  --calcite-color-foreground-3: var(--gm-accent);
  color: var(--gm-bg-dark);
  font-weight: 600;
}

/* ── Loading Spinner ── */
.generating-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 600;
  gap: 16px;
}

.generating-overlay p {
  font-family: var(--gm-font-display);
  color: var(--gm-accent);
  font-size: 16px;
  letter-spacing: 1px;
}

/* ── Stepper help panel ── */
.panel-content calcite-stepper-item p {
  margin: 4px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--gm-text-muted);
}

/* ── Scrollbar Styling ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--gm-border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gm-text-muted);
}

/* ── Extent Coordinate Readout ── */
.extent-readout {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  background: var(--gm-bg-dark);
  border: 1px solid var(--gm-border);
  border-radius: 6px;
  font-family: var(--gm-font-mono);
}

.extent-readout[hidden] {
  display: none;
}

.extent-coord-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.extent-coord-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gm-text-muted);
  min-width: 32px;
  flex-shrink: 0;
}

.extent-coord-value {
  font-size: 11px;
  color: var(--gm-accent);
  text-align: right;
  white-space: nowrap;
}

/* ── Extent Shape Presets (Step 1) ── */
.extent-shape-presets {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0 2px;
}

.extent-presets-label {
  font-size: 11px;
  color: var(--gm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.extent-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.extent-preset-chips calcite-chip {
  cursor: pointer;
}

.extent-shape-presets[hidden] { display: none; }

/* ── Aspect Ratio Hint (Grid Dimensions block) ── */
.aspect-ratio-hint {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0 4px;
  font-size: 11px;
  color: var(--gm-text-muted);
}

.aspect-ratio-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.aspect-ratio-row strong {
  color: var(--gm-accent);
}

.aspect-ratio-sep {
  color: var(--gm-text-muted);
  opacity: 0.5;
}

.aspect-ratio-hint[hidden] {
  display: none;
}

/* ── Focus Indicators (WCAG 2.4.11) ── */
/* Ensure custom interactive elements have visible keyboard focus rings */
.palette-swatch:focus-visible,
.hex-overlay-header calcite-action:focus-visible {
  outline: 3px solid var(--gm-accent);
  outline-offset: 2px;
  z-index: 2;
}

/* ── About Author Panel ── */
.about-author {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0 8px;
}

.about-avatar-icon {
  color: var(--gm-accent);
}

.about-name {
  margin: 0;
  font-family: var(--gm-font-display);
  font-size: 18px;
  color: var(--gm-accent);
  font-weight: 600;
}

.about-bio {
  font-size: 13px;
  color: var(--gm-text-muted);
  line-height: 1.6;
  margin: 4px 0 12px;
}

.about-support-text {
  font-size: 12px;
  color: var(--gm-text-muted);
  margin: 0 0 8px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .hex-overlay {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100%;
    height: 50vh;
    border-radius: 12px 12px 0 0;
  }
}
