/* ================================================
   shared.css — mestaritukki.com
   One file to rule all pages.
   Edit here → changes appear everywhere.

   HOW THIS FILE IS ORGANISED
   ──────────────────────────
   1. Design Tokens  ← 99% of visual changes happen here
   2. Reset
   3. Base body
   4. Canvas layers (matrix / trail / content z-index stack)
   5. Burger / Nav menu
   6. Mobile overrides

   QUICK GUIDE: "I want to change the colour scheme"
   ──────────────────────────────────────────────────
   The six theme colours (purple, red, green, blue, cyan, gold) live in
   shared.js → THEMES object. Each theme sets CSS vars on :root at runtime.
   The fallback values below are only used before shared.js loads (< 50 ms).
   Change the fallback here if you want a different default flash colour.

   QUICK GUIDE: "I want to change the background colour"
   ──────────────────────────────────────────────────────
   Change --bg. Also update bgColor in each page's initMatrix() call so the
   matrix fill colour matches.

   QUICK GUIDE: "I want to change card / panel colours"
   ─────────────────────────────────────────────────────
   Change --card and --card-hover. These are used by all gallery cards,
   app cards, contact form backgrounds, etc.

   QUICK GUIDE: "I want to change the font"
   ─────────────────────────────────────────
   Change the font-family stack in the "Base body" section below.
   If adding a Google Font, add the <link> to every page's <head>.
   ================================================ */


/* ════════════════════════════════════════════════
   1. DESIGN TOKENS
   ════════════════════════════════════════════════
   These CSS custom properties are the single source of truth for
   all colours used across the site. Change a value here and it
   updates everywhere that token is referenced.

   NOTE: --accent, --accent-hover, and --border are overwritten at
   runtime by shared.js → setTheme() based on the user's chosen theme.
   The values below are the FALLBACK (purple theme) shown for the
   fraction of a second before JS executes.
   ════════════════════════════════════════════════ */
:root {
  /* ── Page background ──────────────────────────────────────────
     Deep near-black with a faint violet tint.
     Also update initMatrix({ bgColor: ... }) in each page script
     if you change this, so the matrix rain background matches.     */
  --bg:          #050007;

  /* ── Card / panel backgrounds ────────────────────────────────
     Used by gallery cards, app cards, form containers, etc.
     --card-hover is applied on :hover for a subtle lift effect.   */
  --card:        #16171d;
  --card-hover:  #1d1e26;

  /* ── Typography ───────────────────────────────────────────────
     --text   : primary readable text (near-white)
     --muted  : secondary / placeholder text (grey)               */
  --text:        #f5f3ff;
  --muted:       #9197a6;

  /* ── Accent colours (overwritten at runtime by shared.js) ─────
     These are the purple-theme defaults.
     --accent       : primary interactive colour (buttons, links, highlights)
     --accent-hover : lighter shade for hover states and gradients
     --border       : semi-transparent accent used for borders/dividers  */
  --accent:      #9b5cff;
  --accent-hover:#c4b5fd;
  --border:      rgba(155, 92, 255, 0.15);
}


/* ════════════════════════════════════════════════
   2. RESET
   ════════════════════════════════════════════════
   Removes browser default margin/padding and switches all elements
   to border-box sizing (width includes padding and border).
   Don't change this unless you know what you're doing.
   ════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


/* ════════════════════════════════════════════════
   3. BASE BODY
   ════════════════════════════════════════════════
   Applied to inner scrollable pages (gallery, apps, contact, etc.).
   The home page overrides this with position:fixed + overflow:hidden
   in its own <style> block because it's a full-viewport canvas scene.
   ════════════════════════════════════════════════ */
html, body {
  width: 100vw;
  min-height: 100vh;
  background: var(--bg);

  /* Inner pages scroll vertically. Home page overrides this. */
  overflow-y: auto;
  overflow-x: hidden;

  /* Font stack: add your preferred Google Font name first.
     The rest are system fallbacks in order of preference.
     Example: 'Inter', system-ui, ...                        */
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  color: var(--text);

  /* line-height: comfortable reading rhythm. 1.5–1.7 is standard. */
  line-height: 1.6;

  /* Smooth momentum scrolling on iOS Safari */
  -webkit-overflow-scrolling: touch;
}


/* ════════════════════════════════════════════════
   4. CANVAS Z-INDEX STACK
   ════════════════════════════════════════════════
   The layering order (bottom to top):

     z-index 0     #matrix           Matrix rain — fixed background
     z-index 1     #trail-canvas     Cursor trail — injected by shared.js
     z-index 2     .page-content     All page HTML content
     z-index 2     #logoCanvas       Home page logo (index.html only)
     z-index 1000  .burger-container Nav menu — always on top
     z-index 9999  #theme-switcher   Theme pill (set inline by shared.js)

   IMPORTANT: If you add new fixed-position elements (banners, modals,
   cookie notices, etc.) use z-index 2+ so they appear above the trail.
   ════════════════════════════════════════════════ */

/* Matrix rain canvas — sits at the very back */
#matrix {
  position: fixed;
  inset: 0;          /* shorthand for top/right/bottom/left: 0 */
  z-index: 0;
  pointer-events: none;  /* clicks pass through to the page */
  display: block;
}

/* Cursor trail canvas — injected automatically by shared.js initTrail().
   Sits above matrix but BELOW all page content, creating the "floating
   elements above glowing trail" effect.                                  */
#trail-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  display: block;
}

/* Page content wrapper — wrap all visible page HTML in this div.
   The z-index: 2 ensures content floats above the trail canvas.
   Every inner page uses <div class="page-content"> as its root.  */
.page-content {
  position: relative;
  z-index: 2;
}


/* ════════════════════════════════════════════════
   5. BURGER / NAV MENU
   ════════════════════════════════════════════════
   The burger button and dropdown are injected automatically by
   shared.js → injectNav(). You should not add the HTML manually.
   Style changes here affect every page's nav simultaneously.
   ════════════════════════════════════════════════ */

/* ── Container: fixed top-right ─────────────────────────────── */
.burger-container {
  position: fixed;
  top: 24px;       /* distance from top edge. Mobile override: 16px */
  right: 24px;     /* distance from right edge. Mobile override: 16px */
  z-index: 1000;   /* above all page content */
  touch-action: manipulation;  /* prevents double-tap zoom on mobile */
}

/* ── Button ──────────────────────────────────────────────────── */
.burger-btn {
  width: 50px;     /* button size. Mobile override: 44px */
  height: 50px;
  background: rgba(5, 0, 7, 0.6);          /* frosted glass dark fill */
  border: 1px solid rgba(155, 92, 255, 0.5); /* accent-coloured border */
  border-radius: 12px;  /* corner rounding. 0 = square, 50% = circle */
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;             /* space between the three lines */
  backdrop-filter: blur(10px);  /* frosted glass blur */
  padding: 0;
  transition: background    0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color  0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow    0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.burger-btn:hover,
.burger-btn.active {
  background: rgba(155, 92, 255, 0.2);
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(155, 92, 255, 0.3);  /* accent glow on hover */
}

/* ── The three horizontal lines ─────────────────────────────── */
.burger-line {
  width: 24px;       /* line length. Mobile override: 20px */
  height: 2px;       /* line thickness */
  background: var(--text);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px;
}

/* Animate lines into an X when menu is open */
.burger-btn.active .burger-line:nth-child(1) { transform: translateY(8px)  rotate(45deg);  }
.burger-btn.active .burger-line:nth-child(2) { opacity: 0; transform: scaleX(0);            }
.burger-btn.active .burger-line:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ── Dropdown panel ──────────────────────────────────────────── */
.dropdown-menu {
  position: absolute;
  top: 60px;       /* gap between button bottom and menu top */
  right: 0;
  background: rgba(5, 0, 7, 0.95);
  border: 1px solid rgba(155, 92, 255, 0.5);
  border-radius: 12px;
  backdrop-filter: blur(20px);
  min-width: 220px;   /* minimum menu width. Mobile override: 200px */
  overflow: hidden;

  /* Animation: scales in from top-right corner */
  transform-origin: top right;
  transform: scaleY(0) translateY(-10px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;  /* not clickable while closed */

  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.dropdown-menu.active {
  transform: scaleY(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Individual nav links ────────────────────────────────────── */
.menu-item {
  display: block;
  padding: 16px 20px;    /* vertical rhythm. Mobile override: 14px 18px */
  color: var(--text);
  text-decoration: none;
  font-size: 14px;        /* Mobile override: 12px */
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(155, 92, 255, 0.2);  /* divider between items */
}

.menu-item:last-child { border-bottom: none; }

.menu-item:hover {
  background: rgba(155, 92, 255, 0.2);
  color: var(--accent);
  padding-left: 28px;    /* slide-right effect on hover */
}

.menu-item-icon {
  display: inline-block;
  margin-right: 10px;
  font-size: 16px;
}


/* ════════════════════════════════════════════════
   6. MOBILE OVERRIDES
   ════════════════════════════════════════════════
   Breakpoint: 768px (tablets and below).
   Only values that genuinely need to change on small screens.
   ════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Move burger closer to edges on small screens */
  .burger-container { top: 16px; right: 16px; }

  /* Slightly smaller button so it doesn't crowd the corner */
  .burger-btn { width: 44px; height: 44px; }

  /* Shorter lines to match smaller button */
  .burger-line { width: 20px; }

  /* Menu appears closer to the smaller button */
  .dropdown-menu { top: 54px; min-width: 200px; }

  /* Tighter padding and smaller text in menu items */
  .menu-item { padding: 14px 18px; font-size: 12px; }
}
