/* ===========================================================================
   Apps in Clouds — design system
   Aesthetic: refined "cloud-tech" — deep midnight slate, luminous aurora
   accents (cyan -> violet), atmospheric gradient mesh + grain.
   All foreground/background pairs meet WCAG AAA (>=7:1) for body text.
   =========================================================================== */

:root {
  /* Surfaces */
  --bg: #070b16;
  --bg-2: #0b1224;
  --surface: #111a30;
  --surface-2: #16223f;
  --border: #243352;

  /* Text — tuned for AAA contrast on --bg / --surface */
  --text: #f4f7ff;          /* ~17:1 on --bg */
  --text-soft: #cdd7ef;     /* ~11:1 on --bg */
  --text-muted: #a9b6d6;    /* ~7.4:1 on --bg (AAA body) */

  /* Accents (used for large text / non-text UI, decorative) */
  --aurora-1: #38e1ff;      /* cyan */
  --aurora-2: #7c9bff;      /* periwinkle */
  --aurora-3: #b78bff;      /* violet */
  --accent-strong: #9fd8ff; /* high-contrast accent for AAA link text */

  /* Feedback */
  --ok: #6ff2c0;
  --ok-text: #c9ffe9;
  --err: #ff9aa6;
  --err-text: #ffd6db;

  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1180px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.75);
  --shadow-soft: 0 10px 30px -18px rgba(0, 0, 0, 0.7);

  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Manrope", "Segoe UI", system-ui, sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text-soft);
  line-height: 1.7;
  font-size: 1.05rem;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Atmospheric background: layered aurora mesh + grain */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -2;
  background:
    radial-gradient(40% 50% at 15% 10%, rgba(56, 225, 255, 0.16), transparent 60%),
    radial-gradient(45% 55% at 85% 0%, rgba(183, 139, 255, 0.16), transparent 60%),
    radial-gradient(50% 60% at 60% 100%, rgba(124, 155, 255, 0.12), transparent 60%);
  animation: drift 26s ease-in-out infinite alternate;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.04;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes drift {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(0,-3%,0) scale(1.06); }
}

/* ---------- Accessibility helpers ---------- */
.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  background: var(--aurora-1);
  color: #04121b;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  font-weight: 700;
  z-index: 999;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 3px solid var(--aurora-1);
  outline-offset: 3px;
  border-radius: 4px;
}
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1.4rem; }
main { min-height: 60vh; }
section { padding: 5rem 0; }
.section-tight { padding: 3rem 0; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.6em;
}
h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); }
h2 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h3 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); }
p { margin: 0 0 1.1rem; }
.lead { font-size: clamp(1.1rem, 2vw, 1.35rem); color: var(--text-soft); max-width: 60ch; }
.eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 1rem;
}
.gradient-text {
  background: linear-gradient(100deg, var(--aurora-1), var(--aurora-2) 45%, var(--aurora-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

a { color: var(--accent-strong); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #d7ecff; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 600; font-size: 1rem;
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer; text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn-primary {
  background: linear-gradient(100deg, var(--aurora-1), var(--aurora-2));
  color: #04121b;
  box-shadow: 0 10px 30px -12px rgba(56, 225, 255, 0.6);
}
.btn-primary:hover { transform: translateY(-2px); color: #04121b; }
.btn-ghost {
  background: rgba(255,255,255,0.04);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: rgba(255,255,255,0.09); color: var(--text); transform: translateY(-2px); }
.btn-sm { padding: 0.55rem 1rem; font-size: 0.9rem; }
.btn-danger { background: rgba(255, 120, 130, 0.14); border-color: var(--err); color: var(--err-text); }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(7, 11, 22, 0.72);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; padding-top: 0.9rem; padding-bottom: 0.9rem; }
.brand { display: inline-flex; align-items: center; gap: 0.7rem; text-decoration: none; }
.brand:hover { color: inherit; }
.brand-logo { width: 40px; height: 40px; flex: none; }
.brand-name {
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem;
  color: var(--text); letter-spacing: -0.01em;
}
.brand-name span { color: var(--aurora-1); }

.nav-links { display: flex; align-items: center; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  color: var(--text-soft); text-decoration: none; font-weight: 600;
  padding: 0.5rem 0.85rem; border-radius: 10px; font-size: 0.98rem;
}
.nav-links a:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.nav-links a[aria-current="page"] { color: var(--aurora-1); background: rgba(56,225,255,0.08); }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 0.5rem 0.7rem; cursor: pointer;
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .nav { gap: 0.75rem; padding-top: 0.9rem; padding-bottom: 0.9rem; }
  /* The menu wrapper holds an absolutely-positioned dropdown; remove it from
     the flex flow on mobile so it adds no trailing gap after the toggle. */
  .nav > nav[aria-label="Primary"] { display: contents; }
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0.2rem;
    background: var(--bg-2); border-bottom: 1px solid var(--border);
    padding: 0.8rem 1.4rem 1.2rem; display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 0.8rem 0.9rem; }
}

/* ---------- Hero ---------- */
.hero { padding: 6rem 0 4rem; position: relative; overflow: hidden; }
.hero .container { position: relative; z-index: 1; }
.hero-inner { max-width: 52rem; }
.hero h1 { margin-bottom: 0.4em; }
.hero-cta { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-top: 2rem; }
.hero-orbits {
  position: absolute; right: -4%; top: 10%; width: min(420px, 38vw); aspect-ratio: 1;
  pointer-events: none; opacity: 0.9; z-index: 0;
}

/* staggered entrance */
.reveal { opacity: 0; transform: translateY(18px); animation: rise 0.7s ease forwards; }
.reveal.d1 { animation-delay: 0.05s; }
.reveal.d2 { animation-delay: 0.15s; }
.reveal.d3 { animation-delay: 0.25s; }
.reveal.d4 { animation-delay: 0.35s; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

/* ---------- Cards / grids ---------- */
.grid { display: grid; gap: 1.4rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1040px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid-3, .grid-2, .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { transform: translateY(-4px); border-color: #34507f; box-shadow: var(--shadow); }
.card h3 { margin-bottom: 0.4rem; }
.card-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(56,225,255,0.12); border: 1px solid rgba(56,225,255,0.25);
  margin-bottom: 1rem;
}
.card-icon svg { width: 26px; height: 26px; stroke: var(--aurora-1); }

/* ---------- Portfolio gallery ---------- */
.work-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
@media (max-width: 900px) { .work-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .work-grid { grid-template-columns: 1fr; } }

.work-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
  text-decoration: none; color: inherit;
}
.work-card:hover { transform: translateY(-5px); border-color: #34507f; color: inherit; }
.work-thumb {
  aspect-ratio: 16 / 10; width: 100%; object-fit: cover; display: block;
  background:
    linear-gradient(135deg, rgba(56,225,255,0.18), rgba(183,139,255,0.18)),
    var(--surface-2);
}
.work-thumb-fallback {
  aspect-ratio: 16 / 10; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(56,225,255,0.16), rgba(183,139,255,0.16));
  color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 1.4rem;
}
.work-body { padding: 1.2rem 1.3rem 1.4rem; flex: 1; display: flex; flex-direction: column; }
.work-body h3 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.work-cat {
  font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent-strong); font-weight: 700; margin-bottom: 0.5rem;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 0.9rem; }
.tag {
  font-size: 0.78rem; padding: 0.25rem 0.6rem; border-radius: 999px;
  background: rgb(54, 132, 35); border: 1px solid var(--border); color: var(--text-soft);
}

/* filters */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 2rem; }
.filter-chip {
  padding: 0.45rem 0.95rem; border-radius: 999px; border: 1px solid var(--border);
  background: rgba(255,255,255,0.03); color: var(--text-soft); text-decoration: none;
  font-weight: 600; font-size: 0.9rem;
}
.filter-chip[aria-current="true"] { background: rgba(56,225,255,0.14); color: var(--accent-strong); border-color: rgba(56,225,255,0.4); }
.search-input {
  flex: 1; min-width: 200px; padding: 0.6rem 1rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font: inherit;
}

/* ---------- Detail page gallery ---------- */
.detail-hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 2.4rem; align-items: start; }
@media (max-width: 860px) { .detail-hero { grid-template-columns: 1fr; } }
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem; margin-top: 1.5rem; }
.gallery img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.detail-meta { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.detail-meta dt { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.detail-meta dd { margin: 0.2rem 0 1.1rem; color: var(--text); font-weight: 600; }

/* ---------- Forms ---------- */
.form-wrap { max-width: 640px; }
.field { margin-bottom: 1.3rem; }
.field label { display: block; font-weight: 600; color: var(--text); margin-bottom: 0.45rem; }
.field .req { color: var(--err); }
.field input, .field textarea, .field select {
  width: 100%; padding: 0.85rem 1rem; font: inherit;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.field textarea { min-height: 160px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #8595ba; }
.field-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.35rem; }
.field-error { color: var(--err-text); font-size: 0.9rem; margin-top: 0.35rem; font-weight: 600; }
.hp { position: absolute; left: -9999px; }

/* ---------- Flash messages ---------- */
.flashes { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; gap: 0.7rem; }
.flash { padding: 0.9rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); font-weight: 600; }
.flash-success { background: rgba(111,242,192,0.1); border-color: rgba(111,242,192,0.4); color: var(--ok-text); }
.flash-error { background: rgba(255,120,130,0.1); border-color: var(--err); color: var(--err-text); }
.flash-info { background: rgba(124,155,255,0.12); border-color: rgba(124,155,255,0.4); color: #dbe4ff; }

/* ---------- Stats / values ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.4rem; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { text-align: center; }
.stat .num { font-family: var(--font-display); font-size: clamp(2rem,5vw,3rem); font-weight: 700; color: var(--text); }
.stat .num span { background: linear-gradient(100deg,var(--aurora-1),var(--aurora-3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .label { color: var(--text-muted); font-size: 0.95rem; }

/* ---------- CTA band ---------- */
.cta-band {
  background: linear-gradient(110deg, rgba(56,225,255,0.12), rgba(183,139,255,0.12));
  border: 1px solid var(--border); border-radius: 24px;
  padding: clamp(1.5rem, 5vw, 3rem); text-align: center;
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-2); padding: 3rem 0 2rem; margin-top: 4rem; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 2rem; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-grid h4 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); }
.footer-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.footer-links a { color: var(--text-soft); text-decoration: none; }
.footer-links a:hover { color: var(--aurora-1); }
.footer-bottom { margin-top: 2.4rem; padding-top: 1.4rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.9rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.6rem; }

/* ---------- Admin ---------- */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
@media (max-width: 800px) { .admin-shell { grid-template-columns: 1fr; } }
.admin-side { background: var(--bg-2); border-right: 1px solid var(--border); padding: 1.4rem; }
.admin-main { padding: 2rem; min-width: 0; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 0.8rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table th { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.badge { font-size: 0.72rem; padding: 0.2rem 0.55rem; border-radius: 999px; font-weight: 700; }
.badge-on { background: rgba(111,242,192,0.16); color: var(--ok-text); }
.badge-off { background: rgba(255,120,130,0.16); color: var(--err-text); }
.inline-form { display: inline; }

/* ---------- Team / bios ---------- */
.team-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
@media (max-width: 900px) { .team-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .team-grid { grid-template-columns: 1fr; } }
.team-card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.8rem 1.4rem; text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.team-card:hover { transform: translateY(-4px); border-color: #34507f; }
.team-photo {
  width: 116px; height: 116px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 1rem; display: block;
  border: 2px solid rgba(56,225,255,0.4);
  box-shadow: 0 0 0 6px rgba(56,225,255,0.06);
}
.team-photo-fallback {
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(56,225,255,0.2), rgba(183,139,255,0.2));
  font-family: var(--font-display); font-weight: 700; font-size: 2rem; color: var(--text);
}
.team-card h3 { margin-bottom: 0.2rem; }
.team-role {
  color: var(--accent-strong); font-weight: 600; font-size: 0.95rem;
  margin-bottom: 0.8rem;
}
.team-bio { color: var(--text-muted); font-size: 0.97rem; }
.team-links { display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.team-links a { font-weight: 600; font-size: 0.9rem; }

/* ===========================================================================
   Responsive refinements — consolidated mobile handling
   =========================================================================== */

/* Tablets and below */
@media (max-width: 860px) {
  section { padding: 3.5rem 0; }
  .section-tight { padding: 2.2rem 0; }
  .hero { padding: 3.5rem 0 2.5rem; }
  /* Decorative orbit graphic must never overlap hero text on small screens */
  .hero-orbits { display: none; }
  .detail-hero { gap: 1.6rem; }
}

/* Phones */
@media (max-width: 640px) {
  body { font-size: 1rem; }
  .container { padding: 0 1.1rem; }
  section { padding: 2.8rem 0; }
  .section-tight { padding: 1.8rem 0; }
  .hero { padding: 2.8rem 0 2rem; }

  h1 { font-size: clamp(2rem, 9vw, 2.6rem); }
  h2 { font-size: clamp(1.5rem, 6.5vw, 2rem); }
  h3 { font-size: 1.2rem; }
  .lead { font-size: 1.05rem; }

  /* Full-width, comfortably tappable buttons */
  .hero-cta { gap: 0.7rem; }
  .hero-cta .btn { width: 100%; justify-content: center; }
  .btn { padding: 0.9rem 1.3rem; }

  /* Cards and grids already collapse to 1 col; tighten padding */
  .card { padding: 1.3rem; }
  .grid { gap: 1rem; }
  .work-grid, .team-grid { gap: 1rem; }

  /* Detail page meta + gallery */
  .detail-meta { padding: 1.2rem; }
  .gallery { grid-template-columns: 1fr; }

  /* Stats: 2 cols stays, but shrink numbers a touch */
  .stat .num { font-size: clamp(1.8rem, 9vw, 2.4rem); }

  /* Forms: comfortable tap targets, prevent iOS zoom on focus */
  .field input, .field textarea, .field select { font-size: 16px; padding: 0.8rem 0.9rem; }
  .form-wrap { max-width: 100%; }

  /* Footer stacks; bottom row stacks too */
  .footer-bottom { flex-direction: column; }

  /* Filter/search bar wraps nicely; search takes full width */
  .filter-bar { gap: 0.5rem; }
  .search-input { min-width: 0; width: 100%; flex: 1 1 100%; }

  /* CTA band heading scale */
  .cta-band h2 { font-size: 1.5rem; }
}

/* Admin: make wide tables scroll horizontally inside their cell */
@media (max-width: 800px) {
  .admin-main { padding: 1.4rem 1.1rem; }
  .admin-side {
    border-right: none; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.5rem; padding: 1rem 1.1rem;
  }
  .admin-side nav { width: 100%; }
  .admin-side .footer-links {
    display: flex; flex-wrap: wrap; gap: 0.4rem 1rem;
  }
  /* Tables don't squeeze: let them scroll within their wrapper */
  .admin-table { min-width: 560px; }
}

/* Wrap any admin table in a scroll container via this utility if needed */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Very small phones */
@media (max-width: 400px) {
  .container { padding: 0 0.9rem; }
  h1 { font-size: 1.85rem; }
  .brand-name { font-size: 1.05rem; }
  .eyebrow { letter-spacing: 0.16em; }
  .nav { padding-top: 0.7rem; padding-bottom: 0.7rem; }
}

/* Ensure long words / URLs never cause horizontal overflow */
h1, h2, h3, p, a, .tag, .work-body, .detail-meta dd { overflow-wrap: break-word; }
img { max-width: 100%; height: auto; }

/* ===========================================================================
   Admin responsive — header rows + table-to-cards on phones
   =========================================================================== */
.admin-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 1rem;
}
.row-actions { white-space: nowrap; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }

/* On phones, transform data tables into stacked cards (no horizontal scroll). */
@media (max-width: 680px) {
  .admin-table--cards { min-width: 0; width: 100%; }
  .admin-table--cards thead {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;            /* visually hidden but accessible */
  }
  .admin-table--cards tbody { display: block; }
  .admin-table--cards tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.9rem 0.9rem;
    margin-bottom: 1rem;
  }
  .admin-table--cards td,
  .admin-table--cards th {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 1rem; text-align: right;
    padding: 0.55rem 0; border-bottom: 1px solid var(--border);
    width: auto;
  }
  .admin-table--cards tr > *:last-child { border-bottom: 0; }
  /* Label each cell using its data-label */
  .admin-table--cards td::before,
  .admin-table--cards th::before {
    content: attr(data-label);
    font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-muted); font-weight: 700; text-align: left;
    flex: 0 0 auto; white-space: nowrap; padding-top: 0.15rem;
  }
  /* Cells with no label (shouldn't happen) collapse the gap */
  .admin-table--cards td:not([data-label])::before,
  .admin-table--cards th:not([data-label])::before { content: ""; }
  /* Action buttons go full width, left-aligned, stacked comfortably */
  .admin-table--cards .row-actions {
    justify-content: flex-end;
  }
  .admin-table--cards .row-actions .btn { flex: 0 0 auto; }

  /* Rich cells (multi-line content) stack label above, content full-width left */
  .admin-table--cards td.cell-block {
    flex-direction: column; align-items: stretch; text-align: left; gap: 0.3rem;
  }
  .admin-table--cards td.cell-block::before { padding-top: 0; }
  .admin-table--cards td.cell-block a { word-break: break-all; }
}

/* Code blocks must never force horizontal page scroll */
pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
pre code { white-space: pre; }

/* ===========================================================================
   Gallery lightbox (zoom + pan). Enhanced via js/lightbox.js.
   =========================================================================== */
.gallery-zoomable { cursor: zoom-in; transition: transform 0.15s ease, border-color 0.2s ease; }
.gallery-zoomable:hover { border-color: #34507f; transform: translateY(-2px); }
.gallery-zoomable:focus-visible {
  outline: 2px solid var(--accent-strong); outline-offset: 3px;
}

body.lb-open { overflow: hidden; }

.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
}
.lightbox[hidden] { display: none; }

.lightbox-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 7, 15, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.lightbox-stage {
  position: relative; z-index: 1;
  width: 100vw; height: 100vh;
  display: grid; place-items: center;
  overflow: hidden;
  touch-action: none;            /* we manage pinch/pan ourselves */
}

.lightbox-img {
  max-width: 92vw; max-height: 86vh;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  cursor: zoom-in;
  user-select: none; -webkit-user-select: none;
  will-change: transform;
}
.lightbox.is-zoomed .lightbox-img { transition: none; }

/* Top-right close */
.lb-close {
  position: absolute; top: 1rem; right: 1rem; z-index: 3;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(17, 26, 48, 0.85); color: var(--text);
  border: 1px solid var(--border); cursor: pointer;
}
.lb-close:hover { background: var(--surface-2); border-color: #34507f; }

/* Prev / next */
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(17, 26, 48, 0.85); color: var(--text);
  border: 1px solid var(--border); cursor: pointer;
}
.lb-nav:hover { background: var(--surface-2); border-color: #34507f; }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }
.lb-nav[hidden] { display: none; }

/* Bottom bar: counter + zoom tools */
.lightbox-bar {
  position: absolute; left: 50%; bottom: 1.1rem; transform: translateX(-50%);
  z-index: 3; display: flex; align-items: center; gap: 1rem;
  padding: 0.5rem 0.8rem; border-radius: 999px;
  background: rgba(17, 26, 48, 0.85); border: 1px solid var(--border);
}
.lightbox-count { color: var(--text-soft); font-size: 0.9rem; font-weight: 600; min-width: 3.5ch; text-align: center; }
.lightbox-tools { display: flex; gap: 0.4rem; }
.lb-btn {
  min-width: 38px; height: 34px; padding: 0 0.7rem; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  cursor: pointer; font: 600 1rem/1 var(--font-body);
}
.lb-btn:hover { background: var(--surface-2); border-color: #34507f; }

.lb-close:focus-visible, .lb-nav:focus-visible, .lb-btn:focus-visible {
  outline: 2px solid var(--accent-strong); outline-offset: 2px;
}

@media (max-width: 620px) {
  .lb-nav { width: 42px; height: 42px; }
  .lb-prev { left: 0.5rem; }
  .lb-next { right: 0.5rem; }
  .lightbox-img { max-width: 96vw; max-height: 80vh; }
  .lightbox-bar { bottom: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-img, .gallery-zoomable { transition: none; }
}
