/* ─────────────────────────────────────────────
   Variables
───────────────────────────────────────────── */

:root {
  --bg:           #0c0c0f;
  --surface:      #141418;
  --surface-2:    #1c1c22;
  --border:       rgba(255, 255, 255, 0.07);
  --border-hi:    rgba(255, 255, 255, 0.14);
  --text:         #f0eff4;
  --muted:        #6b7280;
  --accent:       #818cf8;
  --accent-hi:    #a5b4fc;
  --radius:       14px;
  --gap:          10px;
  --ease:         cubic-bezier(0.4, 0, 0.2, 1);

  /* Rainbow card gradients */
  --g-instagram:  linear-gradient(135deg, #e53935, #ff7043);
  --g-behance:    linear-gradient(135deg, #fb8c00, #ffd54f);
  --g-linkedin:   linear-gradient(135deg, #fdd835, #fff176);
  --g-email:      linear-gradient(135deg, #43a047, #81c784);
  --g-bluesky:    linear-gradient(135deg, #1e88e5, #64b5f6);
  --g-reddit:     linear-gradient(135deg, #8e24aa, #ce93d8);
  --g-mapstodon:  linear-gradient(135deg, #ec407a, #f48fb1);
}

[data-theme="light"] {
  --bg:           #f0f0f4;
  --surface:      #ffffff;
  --surface-2:    #f4f4f8;
  --border:       rgba(0, 0, 0, 0.07);
  --border-hi:    rgba(0, 0, 0, 0.15);
  --text:         #0f0f12;
  --muted:        #6b7280;
  --accent:       #4f46e5;
  --accent-hi:    #6366f1;
}

/* ── Mono palette (red · white · black) ── */

[data-palette="mono"] {
  --g-instagram:  linear-gradient(135deg, #c62828, #e53935);
  --g-behance:    linear-gradient(135deg, #1a1a1f, #2c2c32);
  --g-linkedin:   linear-gradient(135deg, #f5f5f5, #e0e0e0);
  --g-email:      linear-gradient(135deg, #b71c1c, #d32f2f);
  --g-bluesky:    linear-gradient(135deg, #212121, #383838);
  --g-reddit:     linear-gradient(135deg, #fafafa, #ededed);
  --g-mapstodon:  linear-gradient(135deg, #d32f2f, #ef5350);
}

/* Mono + light mode: slightly darker light cards */
[data-theme="light"][data-palette="mono"] {
  --g-linkedin: linear-gradient(135deg, #e0e0e0, #cccccc);
  --g-reddit:   linear-gradient(135deg, #e4e4e4, #d0d0d0);
}

/* Dark cards in mono → light text */
[data-palette="mono"] .card--behance .card-label,
[data-palette="mono"] .card--behance .card-arrow {
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* White cards in mono → dark text */
[data-palette="mono"] .card--reddit .card-label,
[data-palette="mono"] .card--reddit .card-arrow {
  color: #3a414b;
  text-shadow: none;
}

/* Hero line: red–white–black (doubled for seamless loop) */
[data-palette="mono"] .hero::before {
  background: linear-gradient(90deg,
    #c62828, #e53935, #f5f5f5, #e0e0e0, #212121, #383838,
    #c62828, #e53935, #f5f5f5, #e0e0e0, #212121, #383838,
    #c62828
  );
  background-size: 200% 100%;
}

/* Train dot: red glow in mono mode */
[data-palette="mono"] .hero::after {
  background: #e53935;
  box-shadow: -8px 0 12px 4px rgba(229, 57, 53, 0.4);
}

/* ─────────────────────────────────────────────
   Reset & Base
───────────────────────────────────────────── */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Futura', 'Century Gothic', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background-color: var(--bg);
  /* Dot-grid — like graph paper or a transit map, slowly drifting */
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem 1rem;
  padding-top: 0.75rem;
  transition: background-color 0.3s, color 0.3s;
  animation: bgDrift 30s linear infinite;
}

[data-theme="light"] body {
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
}

/* ─────────────────────────────────────────────
   Controls (top-right)
───────────────────────────────────────────── */

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

.ctrl-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.35rem 0.7rem;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1.5;
  transition: background 0.2s, border-color 0.2s;
  font-family: inherit;
}

.ctrl-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hi);
}

/* ─────────────────────────────────────────────
   Main layout
───────────────────────────────────────────── */

main {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ─────────────────────────────────────────────
   Hero card
───────────────────────────────────────────── */

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.75rem 1.75rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: relative;
  overflow: hidden;
}

/* Rainbow line — colors scroll opposite to the train for a seamless loop */
.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  /* Gradient repeated 2× so 0% and 100% show the same visible slice */
  background: linear-gradient(90deg,
    #e53935, #ff7043, #fb8c00, #ffd54f, #fdd835, #43a047, #1e88e5, #8e24aa, #ec407a,
    #e53935, #ff7043, #fb8c00, #ffd54f, #fdd835, #43a047, #1e88e5, #8e24aa, #ec407a,
    #e53935
  );
  background-size: 200% 100%;
  animation: routeScroll 6s linear infinite;
}

/* Moving "train" rides along the rainbow line — seamless loop */
.hero::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 3px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  box-shadow: 0 0 10px 3px rgba(255, 255, 255, 0.35);
  animation: trainRide 6s linear infinite;
  pointer-events: none;
}

.hero-logo {
  height: 110px;
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 16px rgba(129, 140, 248, 0.3));
  transition: filter 0.3s;
}

.hero-logo:hover {
  filter: drop-shadow(0 6px 24px rgba(129, 140, 248, 0.5));
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

h1 {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

[data-theme="light"] h1 {
  color: #3a414b;
}

.hero-sub {
  font-size: 0.875rem;
  color: var(--muted);
  letter-spacing: 0.01em;
  line-height: 1.5;
}

[data-theme="light"] .hero-sub {
  color: #3a414b;
  opacity: 0.65;
}

/* ─────────────────────────────────────────────
   Bento grid
───────────────────────────────────────────── */

.bento {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 110px 110px 110px 110px;
  grid-template-areas:
    "instagram instagram behance"
    "instagram instagram linkedin"
    "email     bluesky   reddit"
    "deco-1    mapstodon deco-2";
  gap: var(--gap);
}

/* ─────────────────────────────────────────────
   Animations — transit-themed
───────────────────────────────────────────── */

/* Dot-grid background slowly drifts like a map in motion */
@keyframes bgDrift {
  from { background-position: 0 0; }
  to   { background-position: 22px 22px; }
}

/* Cards arrive like stations lighting up on a transit map */
@keyframes arrive {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Rainbow scrolls right→left (opposite to the train) */
@keyframes routeScroll {
  from { background-position: 0% 0; }
  to   { background-position: 100% 0; }
}

/* Train travels left→right; overflow:hidden on .hero hides the reset */
@keyframes trainRide {
  from { left: -40px; }
  to   { left: 100%; }
}

/* Pulsing "next departure" dot on deco tiles */
@keyframes blink {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.3); }
}

/* Deco icon hops like a departure notification */
@keyframes decoHop {
  0%, 75%, 100% { transform: translateY(0); }
  82%           { transform: translateY(-7px); }
  91%           { transform: translateY(-2px); }
}

/* Hero & footer entrance */
.hero   { animation: arrive 0.4s var(--ease) both; }
footer  { animation: arrive 0.4s var(--ease) 0.52s both; }

/* Bento cards arrive one by one — stations lighting up */
.bento > *:nth-child(1) { animation: arrive 0.38s var(--ease) 0.10s both; }
.bento > *:nth-child(2) { animation: arrive 0.38s var(--ease) 0.17s both; }
.bento > *:nth-child(3) { animation: arrive 0.38s var(--ease) 0.23s both; }
.bento > *:nth-child(4) { animation: arrive 0.38s var(--ease) 0.29s both; }
.bento > *:nth-child(5) { animation: arrive 0.38s var(--ease) 0.35s both; }
.bento > *:nth-child(6) { animation: arrive 0.38s var(--ease) 0.40s both; }
.bento > *:nth-child(7) { animation: arrive 0.38s var(--ease) 0.38s both; }
.bento > *:nth-child(8) { animation: arrive 0.38s var(--ease) 0.44s both; }
.bento > *:nth-child(9) { animation: arrive 0.38s var(--ease) 0.50s both; }

/* ─────────────────────────────────────────────
   Card base
───────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.2s var(--ease),
    border-color 0.2s,
    background 0.2s,
    box-shadow 0.2s;
}

/* Shine sweep on hover */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 30%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  filter: brightness(1.08) saturate(1.08);
}

.card:hover::after {
  opacity: 1;
}

/* Icon */
.card-icon {
  font-size: 1.75rem;
  line-height: 1;
  display: block;
  flex: 1;
  display: flex;
  align-items: flex-start;
}

/* Bottom row: label + arrow */
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.card-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.card-label--muted {
  color: rgba(255, 255, 255, 0.65);
  text-shadow: none;
}

.card-arrow {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  opacity: 0;
  transform: translate(-3px, 3px);
  transition: opacity 0.2s, transform 0.2s var(--ease);
}

.card:hover .card-arrow {
  opacity: 1;
  transform: translate(0, 0);
}

/* ── Platform grid areas + rainbow gradients ── */

.card--instagram { grid-area: instagram; background: var(--g-instagram); }
.card--behance   { grid-area: behance;   background: var(--g-behance); }
.card--linkedin  { grid-area: linkedin;  background: var(--g-linkedin); color: #3a414b; }
.card--email     { grid-area: email;     background: var(--g-email); }
.card--bluesky   { grid-area: bluesky;   background: var(--g-bluesky); }
.card--reddit    { grid-area: reddit;    background: var(--g-reddit); }
.card--mapstodon { grid-area: mapstodon; background: var(--g-mapstodon); }

/* Behance (orange/yellow) + LinkedIn (yellow) — use dark text */
.card--behance .card-label,
.card--behance .card-arrow,
.card--linkedin .card-label,
.card--linkedin .card-arrow {
  color: #3a414b;
  text-shadow: none;
}
.card--behance .card-label--muted,
.card--linkedin .card-label--muted {
  color: rgba(58, 65, 75, 0.55);
}

/* Coloured cards: no background transition on hover, just lift + shine */
.card--instagram,
.card--behance,
.card--linkedin,
.card--email,
.card--bluesky,
.card--reddit,
.card--mapstodon {
  border-color: rgba(255, 255, 255, 0.12);
  transition:
    transform 0.2s var(--ease),
    box-shadow 0.2s,
    filter 0.2s;
}
.card--deco-1    { grid-area: deco-1; }
.card--deco-2    { grid-area: deco-2; }

/* ── Featured (Instagram, 2×2) ── */

.card--featured .card-icon {
  font-size: 2.75rem;
}

/* ── Deco tiles ── */

.card--deco {
  background: transparent;
  border-style: dashed;
  border-color: var(--border);
  transition:
    transform 0.2s var(--ease),
    background 0.2s,
    border-color 0.2s,
    border-style 0.15s;
}

[data-theme="light"] .card--deco {
  background: #2e2e35;
  border-style: solid;
  border-color: transparent;
}

[data-theme="light"] .card--deco .card-label--muted {
  color: rgba(255, 255, 255, 0.55);
}

.card--deco::after {
  display: none; /* no shine sweep on deco tiles */
}

/* Pulsing "next departure" indicator */
.card--deco::before {
  content: '';
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 2.5s ease-in-out infinite;
  pointer-events: none;
}

.card--deco-2::before {
  animation-delay: 1.25s;
}

.card--deco:hover {
  background: var(--surface);
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .card--deco:hover {
  background: #3a3a42;
  border-color: transparent;
}

.card--deco .card-icon {
  font-size: 1.5rem;
}

/* Icon hops like a departure-board notification */
.deco-icon {
  display: inline-block;
  animation: decoHop 4.5s ease-in-out infinite;
  animation-delay: 1.8s;
}

.card--deco-2 .deco-icon {
  animation-delay: 3.6s;
}

/* ─────────────────────────────────────────────
   Footer
───────────────────────────────────────────── */

footer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-link {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
  padding: 0;
}

.footer-link:hover {
  color: var(--accent-hi);
}

/* ─────────────────────────────────────────────
   Transit Fact popup
───────────────────────────────────────────── */

.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.popup-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  z-index: 201;
  opacity: 0;
  transition: opacity 0.25s, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.popup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.popup h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.875rem;
}

.popup p {
  color: var(--text);
  line-height: 1.65;
  font-size: 0.925rem;
  margin-bottom: 0.75rem;
}

.popup-source {
  font-size: 0.8rem !important;
  color: var(--muted) !important;
}

.popup-source a {
  color: var(--accent);
  text-decoration: none;
}

.popup-source a:hover {
  text-decoration: underline;
}

.popup-close-btn {
  margin-top: 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 1.1rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.popup-close-btn:hover {
  background: var(--surface);
  border-color: var(--border-hi);
}

/* ─────────────────────────────────────────────
   Impressum modal
───────────────────────────────────────────── */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.is-open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 2rem;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.25s var(--ease);
}

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

.modal h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  margin-top: 1.5rem;
}

.modal h2:first-of-type {
  margin-top: 0;
}

.modal h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

[data-theme="light"] .modal h2,
[data-theme="light"] .modal h3,
[data-theme="light"] .modal strong {
  color: #3a414b;
}

.modal p {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.65;
  margin-bottom: 0.75rem;
}

.modal a {
  color: var(--accent);
  text-decoration: none;
}

.modal a:hover {
  text-decoration: underline;
}

.modal strong {
  color: var(--text);
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.3rem 0.55rem;
  border-radius: 0.5rem;
  transition: color 0.2s, background 0.2s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-2);
}

/* ─────────────────────────────────────────────
   Bot protection placeholder
───────────────────────────────────────────── */

.protected [data-ready="false"] {
  opacity: 0.45;
}

/* ─────────────────────────────────────────────
   Focus styles
───────────────────────────────────────────── */

.card:focus-visible,
.ctrl-btn:focus-visible,
.footer-link:focus-visible,
.modal-close:focus-visible,
.popup-close-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─────────────────────────────────────────────
   Reduced motion
───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────────
   Responsive — tablet / large mobile
───────────────────────────────────────────── */

@media (max-width: 540px) {
  body {
    padding: 0.5rem;
    padding-top: 0.35rem;
  }

  main {
    gap: 8px;
  }

  .hero {
    padding: 1.25rem;
    gap: 1rem;
  }

  .hero-logo {
    height: 80px;
  }

  .bento {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 100px 90px 90px 90px 90px;
    grid-template-areas:
      "instagram instagram"
      "behance   linkedin"
      "email     bluesky"
      "reddit    mapstodon"
      "deco-1    deco-2";
    gap: 8px;
  }

  .card--featured .card-icon {
    font-size: 2rem;
  }
}

@media (max-width: 380px) {
  .hero {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  .hero-logo {
    height: 75px;
  }

  .bento {
    grid-template-rows: 90px 80px 80px 80px 80px;
    gap: 7px;
  }

  .card {
    padding: 0.75rem;
  }

  .card-icon {
    font-size: 1.5rem !important;
  }
}

/* ─────────────────────────────────────────────
   Responsive — landscape (small screens)
───────────────────────────────────────────── */

@media (max-height: 520px) and (orientation: landscape) {
  body {
    align-items: flex-start;
    padding: 0.5rem;
  }

  main {
    max-width: 100%;
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: 1fr auto;
    grid-template-areas:
      "hero  bento"
      "footer bento";
    gap: 8px;
    min-height: calc(100vh - 1rem);
  }

  .hero {
    grid-area: hero;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 1rem;
  }

  .hero-logo {
    height: 64px;
  }

  h1 {
    font-size: 1.4rem;
  }

  .bento {
    grid-area: bento;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 80px 80px 80px 80px;
    grid-template-areas:
      "instagram instagram behance"
      "instagram instagram linkedin"
      "email     bluesky   reddit"
      "deco-1    mapstodon deco-2";
  }

  footer {
    grid-area: footer;
    align-self: end;
  }
}
