/* =========================================================
   Portfolio gallery v2 — professional, with light/dark themes
   Sans: Plus Jakarta Sans   Mono: JetBrains Mono
   Accent: teal, tuned per scheme for WCAG AA contrast
   ========================================================= */

/* ---- Light scheme (default) ---- */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;

  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --on-accent: #ffffff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 22px 45px -26px rgba(15, 23, 42, 0.45);

  --maxw: 1320px;
  --gap: clamp(1.1rem, 2.6vw, 2.25rem);
  --radius: 10px;

  --sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  color-scheme: light;
}

/* ---- Dark scheme: explicit toggle ---- */
[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #0f172a;
  --surface-2: #131f38;
  --border: #1e293b;
  --border-strong: #334155;

  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #7c8aa0;

  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --on-accent: #04221f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 50px -24px rgba(0, 0, 0, 0.7);

  color-scheme: dark;
}

/* ---- Dark scheme: follow OS when no explicit choice ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #0f172a;
    --surface-2: #131f38;
    --border: #1e293b;
    --border-strong: #334155;

    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-faint: #7c8aa0;

    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: rgba(45, 212, 191, 0.12);
    --on-accent: #04221f;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 24px 50px -24px rgba(0, 0, 0, 0.7);

    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a {
  color: inherit;
}

/* ----------------------------- Masthead ----------------------------- */

.masthead {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2rem) var(--gap) 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: clamp(1.75rem, 5vw, 3.5rem);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand__sub {
  color: var(--text-faint);
  font-weight: 500;
  margin-left: 0.35rem;
}

.brand:hover .brand__sub {
  color: var(--accent);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle .icon {
  width: 1.15rem;
  height: 1.15rem;
}

/* show the icon for the scheme you can switch TO */
.icon--sun {
  display: none;
}
.icon--moon {
  display: block;
}
[data-theme="dark"] .icon--sun {
  display: block;
}
[data-theme="dark"] .icon--moon {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon--sun {
    display: block;
  }
  :root:not([data-theme="light"]) .icon--moon {
    display: none;
  }
}

.intro {
  padding-bottom: clamp(1.5rem, 4vw, 2.75rem);
  border-bottom: 1px solid var(--border);
}

.intro__eyebrow {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}

.intro__title {
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0.6rem 0 0;
}

.intro__lede {
  max-width: 52ch;
  margin: 0.9rem 0 0;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ----------------------------- Gallery ------------------------------ */

.gallery {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 2.75rem) var(--gap) 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: clamp(1.5rem, 3vw, 2.5rem);
}

.card {
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(14px);
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: calc(var(--i) * 70ms);
}

@keyframes rise {
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* --------------------------- The frame ------------------------------ */

.frame {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--surface-2);
  background-image: radial-gradient(
    var(--border-strong) 1px,
    transparent 1px
  );
  background-size: 16px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
}

.frame__doc {
  position: absolute;
  top: 0;
  left: 0;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none; /* the overlay handles all interaction */
  background: #fff;
}

.frame__doc--img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transform: none;
}

/* Interaction-blocking, click-to-open overlay */
.frame__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0.85rem;
  text-decoration: none;
  background: linear-gradient(
    to top,
    rgba(2, 6, 23, 0.28) 0%,
    rgba(2, 6, 23, 0) 42%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.frame__cta {
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--on-accent);
  background: var(--accent);
  padding: 0.45rem 0.8rem;
  border-radius: 7px;
  box-shadow: var(--shadow-sm);
  transform: translateY(6px);
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.card:hover .frame {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.card:hover .frame__overlay,
.frame__overlay:focus-visible {
  opacity: 1;
}

.card:hover .frame__cta,
.frame__overlay:focus-visible .frame__cta {
  transform: none;
}

.frame__overlay:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* --------------------------- Card meta ------------------------------ */

.card__meta {
  padding: 0.95rem 0.1rem 0;
}

/* Year: offset above the title, small monospace */
.card__year {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 0.3rem;
}

.card__title {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  line-height: 1.25;
}

.card__desc {
  margin: 0.4rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 46ch;
}

.card__tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

/* Role: emphasised chip sitting just before the tags */
.role {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.24rem 0.66rem;
}

.tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

/* --------------------------- Colophon ------------------------------- */

.colophon {
  max-width: var(--maxw);
  margin: clamp(3rem, 8vw, 6rem) auto 0;
  padding: 1.25rem var(--gap) 2.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.colophon a {
  color: var(--text-muted);
  text-decoration: none;
}

.colophon a:hover {
  color: var(--accent);
}
