/* ==========================================================================
   1. CONFIGURATION
   Every colour, font, spacing and timing value the dashboard uses lives here.
   Change a value once, and it updates everywhere it's used.
   ========================================================================== */
:root {
  /* --- Background image ---------------------------------------------------
     This is the ONE place the background image is referenced. Drop a new
     file into /images and update the path below — nothing else to touch. */
  --background-image: url('../images/background-1.jpg');
  --overlay-opacity: 0.9; /* 0 = image fully visible, 1 = solid background-color */

  /* --- Colour system -------------------------------------------------------
     Named, reusable roles rather than one-off hex codes. */
  --color-void: #12100d;         /* page background, shows through the overlay */
  --color-surface: #1c1915;      /* card / popup surface */
  --color-surface-hover: #262119;
  --color-border: rgba(233, 224, 210, 0.12);
  --color-border-strong: rgba(233, 224, 210, 0.24);

  --color-text: #eee8dc;         /* primary text */
  --color-text-muted: #9b9186;   /* secondary / descriptive text */

  --color-primary: #e2963c;      /* amber — primary accent, shortcuts, focus */
  --color-primary-soft: rgba(226, 150, 60, 0.14);
  --color-secondary: #3f9c92;    /* teal — secondary accent, hover states */

  /* --- Glass material -------------------------------------------------------
     Translucent surfaces for cards/popup/search — tinted, blurred, with a
     faint light border standing in for a glass edge. Tune opacity/blur here. */
  --glass-bg: rgba(28, 25, 21, 0.4);
  --glass-bg-hover: rgba(40, 35, 27, 0.52);
  --glass-bg-strong: rgba(24, 21, 18, 0.58); /* popup — a touch less transparent for readability */
  --glass-border: rgba(238, 232, 220, 0.16);
  --glass-border-strong: rgba(238, 232, 220, 0.3);
  --glass-blur: 20px;
  --glass-saturate: 160%;
  --glass-sheen: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0) 45%);

  /* Back-compat aliases matching the brief's original variable names,
     in case other snippets or future code expect these exact names. */
  --background-color: var(--color-void);
  --text-color: var(--color-text);
  --primary-color: var(--color-primary);
  --secondary-color: var(--color-secondary);

  /* --- Typography ------------------------------------------------------- */
  --font-ui: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  /* --- Layout & spacing --------------------------------------------------- */
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-pill: 999px;
  --gap: 1.25rem;
  --max-content-width: 860px;

  /* --- Motion -------------------------------------------------------------
     One easing curve, reused everywhere, so motion feels consistent. */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --duration: 180ms;
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-ui);
  color: var(--color-text);
  background: var(--color-void);
  overflow: hidden; /* desktop-first: the dashboard is designed to fit 100vh */
}

button,
input {
  font-family: inherit;
  color: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ==========================================================================
   3. BACKGROUND LAYER
   Two stacked, fixed layers behind everything: the image, then a flat
   overlay whose opacity is controlled by --overlay-opacity above.
   ========================================================================== */
.background-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: var(--background-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--color-void);
  opacity: var(--overlay-opacity);
  pointer-events: none;
}

.particles-canvas {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: block;
  pointer-events: none;
}

/* ==========================================================================
   4. APP SHELL
   ========================================================================== */
.app {
  position: relative;
  z-index: 3;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  justify-content: flex-end;
  padding: 1.5rem 2rem 0;
}

.app-clock {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.dashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: 1.5rem 2rem 3rem;
}

/* ==========================================================================
   5. SEARCH BAR
   ========================================================================== */
.search-wrap {
  position: relative;
  width: 100%;
  max-width: var(--max-content-width);
}

.search-bar {
  width: 100%;
  padding: 0.95rem 3rem 0.95rem 1.5rem;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 1rem;
  transition: border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.search-bar::placeholder {
  color: var(--color-text-muted);
}

.search-bar:focus {
  border-color: var(--color-primary);
  background: var(--glass-bg-hover);
}

.search-hint {
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  pointer-events: none;
}

/* ==========================================================================
   6. CARD GRID
   ========================================================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  width: 100%;
  max-width: var(--max-content-width);
}

.card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.1rem 1.1rem 1rem;
  aspect-ratio: 1 / 0.95;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-left: 2px solid var(--color-primary);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glass-sheen);
  pointer-events: none;
}

.card:hover,
.card:focus-visible {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-strong);
  border-left-color: var(--color-secondary);
  transform: translateY(-2px);
}

.card-key {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
}

.card-icon {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--color-primary);
}

.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-desc {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--color-text-muted);
}

/* ==========================================================================
   7. POPUP (single reusable component, content swapped by JS)
   ========================================================================== */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

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

.popup {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 480px;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  animation: popup-in var(--duration) var(--ease);
}

.popup::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--glass-sheen);
  pointer-events: none;
}

.popup-header,
.popup-body,
.popup-footer {
  position: relative;
}

@keyframes popup-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.popup-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.popup-key {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-void);
  background: var(--color-primary);
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.popup-title {
  flex: 1;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.popup-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
}

.popup-close:hover {
  color: var(--color-text);
}

.popup-description {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.popup-actions {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.popup-action {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration) var(--ease),
    border-color var(--duration) var(--ease);
}

.popup-action:hover,
.popup-action:focus-visible {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

.popup-action kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-primary);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.4rem;
}

.popup-status {
  min-height: 1.2rem;
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-secondary);
}

.popup-footer {
  display: flex;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.popup-footer kbd {
  font-family: var(--font-mono);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 0.05rem 0.35rem;
  margin-right: 0.3rem;
}

/* ==========================================================================
   8. RESPONSIVE
   Desktop is the priority; this keeps things usable if the window is
   narrow without touching the desktop layout above.
   ========================================================================== */
@media (max-width: 720px) {
  body {
    overflow-y: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
