/* ============================================================
   Digital Insomnia — Phillip Marsland Photography
   Responsive dark portfolio stylesheet
   ============================================================ */

:root {
  --bg: #0d0f12;
  --bg-raised: #15181d;
  --text: #e8e6e1;
  --muted: #9a978f;
  --accent: #d4a24e;
  --accent-soft: rgba(212, 162, 78, 0.14);
  --line: #26292f;
  --radius: 10px;
  --header-h: 64px;
  --header-bg: rgba(13, 15, 18, 0.92);
  --maxw: 1280px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; width: 100%; }

img { max-width: 100%; display: block; }

a { color: inherit; }

/* ---------- Theme toggle button ---------- */

.theme-toggle {
  order: 99; /* always the last item on the bar — far right */
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
  transition: background 0.2s;
}

.theme-toggle:hover { background: var(--bg-raised); }

/* ---------- Light theme ---------- */

:root[data-theme="light"] {
  --bg: #f5f3ef;
  --bg-raised: #ffffff;
  --text: #24272c;
  --muted: #6d7076;
  --accent: #a97b22;
  --accent-soft: rgba(169, 123, 34, 0.12);
  --line: #ddd8cf;
  --header-bg: rgba(245, 243, 239, 0.92);
}

:root[data-theme="light"] .btn-primary { color: #ffffff; }

:root[data-theme="light"] .tile::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02) 30%, rgba(255, 255, 255, 0.92) 100%);
}

:root[data-theme="light"] .tile .tile-count {
  background: rgba(255, 255, 255, 0.75);
}

:root[data-theme="light"] .tile {
  background-color: #ffffff;
}

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  white-space: nowrap;
}

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

.brand-logo {
  display: block;
  height: 44px;
  width: auto;
  filter: brightness(1.45); /* lift the blue-grey logo off the dark header */
}

:root[data-theme="light"] .brand-logo { filter: none; }

@media (max-width: 480px) {
  .brand-logo { height: 36px; }
}

/* Desktop nav */
.main-nav {
  margin-left: auto; /* nav hugs the right, toggle sits beyond it */
}

.main-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.4rem;
}

/* subtle separator between the info links and the galleries */
.nav-divider {
  width: 1px;
  height: 1.2rem;
  background: var(--line);
  flex: none;
}

.main-nav a {
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.main-nav a:hover { color: var(--text); }

.main-nav a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 1.15rem;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

/* ---------- Logo hero banner ---------- */

.logo-hero {
  display: flex;
  justify-content: center;
  padding: 2.2rem 1rem 1.4rem;
  background: linear-gradient(180deg, var(--bg-raised) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}

.logo-hero img {
  width: min(520px, 84vw);
  height: auto;
}

/* parallax shrink as the user scrolls away */
@media (prefers-reduced-motion: no-preference) {
  .logo-hero img { will-change: transform; }
}

/* small header logo hides while the big one is on screen */
.header-inner .brand {
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(0);
}

.logo-hero-visible .header-inner .brand {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

/* ---------- Hero (home page, photo carousel) ---------- */

.hero {
  position: relative;
  min-height: calc(78vh - var(--header-h));
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.hero-carousel {
  position: absolute;
  inset: 0;
}

.hero-slides, .hero-slide {
  position: absolute;
  inset: 0;
}

.hero-slide {
  background: center / cover no-repeat;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 1.1s ease, transform 6s linear;
}

.hero-slide.active {
  opacity: 1;
  transform: scale(1);
}

.hero-slide img { display: none; } /* preload helper only */

/* readability scrim over the photo */
.hero-overlay {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3.5rem 1.25rem 4.5rem;
  background:
    linear-gradient(180deg, rgba(13, 15, 18, 0.55) 0%, rgba(13, 15, 18, 0.25) 45%, rgba(13, 15, 18, 0.65) 100%);
}

.hero-inner h1 {
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 300;
  letter-spacing: 0.06em;
  line-height: 1.15;
  color: #ffffff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.hero-inner h1 strong { font-weight: 700; display: block; }

.hero-tagline {
  margin-top: 0.9rem;
  color: #f2f0ec;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  max-width: 42rem;
  margin-inline: auto;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9), 0 0 18px rgba(0, 0, 0, 0.55);
}

.hero-actions {
  margin-top: 2.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
}

/* pagination dots */
.hero-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.1rem;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 0.55rem;
}

.hero-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: background 0.25s, transform 0.25s;
}

.hero-dot:hover { transform: scale(1.25); }

.hero-dot.active {
  background: #ffffff;
  transform: scale(1.15);
}

:root[data-theme="light"] .hero-overlay {
  background:
    linear-gradient(180deg, rgba(13, 15, 18, 0.45) 0%, rgba(13, 15, 18, 0.18) 45%, rgba(13, 15, 18, 0.55) 100%);
}

@media (max-width: 640px) {
  .hero { min-height: calc(62vh - var(--header-h)); }
  .hero-dots { bottom: 0.8rem; }
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.6rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: var(--accent);
  color: #17130a;
}

.btn-primary:hover { box-shadow: 0 6px 22px rgba(212, 162, 78, 0.35); }

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: transparent;
}

.btn-ghost:hover { background: var(--bg-raised); }

/* ghost button over the hero photo needs its own scrim in both themes */
.hero .btn-ghost {
  border-color: rgba(255, 255, 255, 0.55);
  color: #ffffff;
  background: rgba(10, 12, 15, 0.45);
  backdrop-filter: blur(3px);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.hero .btn-ghost:hover {
  background: rgba(10, 12, 15, 0.7);
  border-color: #ffffff;
}

.btn-sm { padding: 0.5rem 1.1rem; font-size: 0.85rem; }

button.btn { cursor: pointer; font-family: inherit; }

/* ---------- Category tiles (home) ---------- */

.section { max-width: var(--maxw); margin: 0 auto; padding: 3.5rem 1.25rem; }

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-top: 2.2rem;
  margin-bottom: 1.4rem;
}

.section .section-title { margin-top: 0; }

.section-title small {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 190px;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  background: var(--bg-raised) center / cover no-repeat;
  border: 1px solid var(--line);
  transition: transform 0.2s, border-color 0.2s;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(13, 15, 18, 0.05) 30%, rgba(13, 15, 18, 0.88) 100%);
}

.tile:hover { transform: translateY(-4px); border-color: var(--accent); }

.tile h3 { position: relative; font-size: 1.05rem; font-weight: 600; }

.tile p {
  position: relative;
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

.tile .tile-count {
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(13, 15, 18, 0.65);
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
}

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

.page-head {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.4rem 1.25rem 1.4rem;
}

.page-head h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 600; }

.page-head .crumbs {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.page-head .crumbs a { color: var(--muted); text-decoration: none; }
.page-head .crumbs a:hover { color: var(--accent); }

.gallery-grid {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem 3.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.ph {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: zoom-in;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  aspect-ratio: 4 / 3;
}

.ph img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.ph:hover img { transform: scale(1.04); }

.ph figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1.8rem 0.8rem 0.6rem;
  background: linear-gradient(180deg, transparent, rgba(13, 15, 18, 0.85));
  font-size: 0.78rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.25s;
}

.ph:hover figcaption { opacity: 1; }

.gallery-empty {
  color: var(--muted);
  padding: 3rem 0;
  text-align: center;
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

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

.gallery-pages {
  max-width: var(--maxw);
  margin: 0 auto 3rem;
  padding: 0 1.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

.pg-btn {
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--muted);
  border-radius: 8px;
  min-width: 2.3rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.pg-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.pg-btn.active {
  background: var(--accent);
  color: #17130a;
  border-color: var(--accent);
  font-weight: 700;
}

.pg-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

:root[data-theme="light"] .pg-btn.active { color: #ffffff; }

/* ---------- About / contact ---------- */

.about-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 3rem 1.25rem;
}

.about-wrap h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 600; margin-bottom: 1.2rem; }

.about-wrap p { color: var(--muted); margin-bottom: 1rem; }

.contact-list {
  list-style: none;
  margin-top: 1.8rem;
  display: grid;
  gap: 0.6rem;
}

.contact-list a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
}

.contact-list .icon { color: var(--accent); margin-right: 0.5rem; }

.fineprint {
  margin-top: 2.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- Legal pages helpers ---------- */

.plain-list {
  margin: 0 0 1rem 1.2rem;
  color: var(--muted);
}

.plain-list li { margin-bottom: 0.45rem; }

.plain-list strong { color: var(--text); }

.text-link { color: var(--text); text-decoration-color: var(--accent); }

.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

/* ---------- Branded right-click menu ---------- */

.ctx-menu {
  position: fixed;
  z-index: 120;
  max-width: 300px;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
  padding: 0.9rem 1rem 1rem;
  display: none;
}

.ctx-menu.show { display: block; animation: ctx-pop 0.18s ease; }

@keyframes ctx-pop {
  from { opacity: 0; transform: scale(0.94) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.ctx-title {
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
}

.ctx-title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 0.45rem;
}

.ctx-msg {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 0.7rem;
}

.ctx-link {
  display: inline-block;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.ctx-link:hover { border-bottom-color: var(--accent); }

/* ---------- Cookie consent banner ---------- */

.cookie-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 90;
  max-width: 640px;
  margin: 0 auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  padding: 1rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem 1.2rem;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cookie-banner.show { opacity: 1; transform: translateY(0); }

.cookie-text {
  flex: 1 1 320px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

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

.cookie-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .cookie-banner { left: 0.6rem; right: 0.6rem; bottom: 0.6rem; }
  .cookie-actions { width: 100%; }
  .cookie-actions .btn { flex: 1; text-align: center; }
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 6, 8, 0.94);
  padding: 2.5rem 1rem;
}

.lightbox.open { display: flex; }

/* Scales ANY uploaded image to fit the viewport - a 6000px camera
   original is shrunk to the screen, a small one is never stretched up. */
.lightbox img {
  display: block;
  flex: 0 1 auto;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: calc(100vw - 2rem);   /* container padding */
  max-height: calc(100vh - 8rem);  /* padding + room for the caption */
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.lb-btn {
  position: absolute;
  background: rgba(13, 15, 18, 0.7);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
}

.lb-btn:hover { background: var(--bg-raised); }

.lb-close { top: 1rem; right: 1rem; }
.lb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.lb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.lb-caption {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 90%;
  text-align: center;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 2rem;
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.4rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.footer-inner a { color: var(--muted); text-decoration: none; }
.footer-inner a:hover { color: var(--accent); }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
}

.socials {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

.socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 0.2s, transform 0.15s;
}

.socials a:hover {
  color: var(--accent);
  transform: translateY(-2px);
}

.socials svg { width: 20px; height: 20px; }

/* ---------- Responsive breakpoints ---------- */

@media (max-width: 820px) {
  .nav-toggle { display: block; }

  /* theme toggle sits just left of the hamburger, both at the right edge */
  .theme-toggle { order: 0; margin-left: auto; }

  .main-nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--line);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .main-nav.open { max-height: 420px; }

  .main-nav ul {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.6rem 1.25rem 1rem;
  }

  .main-nav a {
    display: block;
    padding: 0.7rem 0.2rem;
    border-bottom: 1px solid var(--line);
    font-size: 1rem;
  }

  .main-nav a.active { border-bottom-color: var(--accent); }

  /* divider renders as a horizontal rule inside the dropdown */
  .nav-divider {
    width: auto;
    height: 1px;
    margin: 0.4rem 0;
  }

  .hero { min-height: calc(66vh - var(--header-h)); }
}

@media (max-width: 480px) {
  .tile-grid { grid-template-columns: 1fr 1fr; }
  .tile { min-height: 150px; }
  .gallery-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
  .lb-prev, .lb-next { padding: 0.9rem 0.7rem; }
  .lightbox { padding: 1rem 0.5rem; }
  .lightbox img { max-width: calc(100vw - 6rem); max-height: calc(100vh - 9rem); }
}
