/* ============================================================
   Phi Guitars – Stylesheet
   Design tokens derived from the Fibonacci sequence & golden ratio (φ ≈ 1.618)
   Spacing scale (px): 5 · 8 · 13 · 21 · 34 · 55 · 89
   ============================================================ */

/* --- Custom Properties ------------------------------------ */
:root {
  /* Earth-tone dark palette */
  --bg:          #0c0a07;
  --bg-surface:  #141008;
  --bg-card:     #1a150f;
  --border:      #282015;
  --text:        #f4ecdf;
  --text-muted:  #a89880;
  --accent:      #c48a3a;
  --accent-dim:  #8b6914;
  --accent-glow: rgba(196,138,58,.12);
  --danger:      #b85c3a;
  --focus-ring:  #c48a3a;

  /* Golden ratio */
  --phi: 1.618;

  /* Fibonacci spacing */
  --sp-xs:  5px;
  --sp-sm:  8px;
  --sp-md:  13px;
  --sp-lg:  21px;
  --sp-xl:  34px;
  --sp-2xl: 55px;
  --sp-3xl: 89px;

  /* Typography */
  --font: system-ui, -apple-system, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

/* --- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.618; /* golden ratio line height */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a   { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Screen-reader only ----------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --- Skip Navigation -------------------------------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-md);
  background: var(--accent);
  color: var(--bg);
  padding: var(--sp-sm) var(--sp-md);
  z-index: 1000;
  border-radius: 0 0 4px 4px;
  font-weight: 600;
}
.skip-link:focus {
  top: 0;
}

/* --- Header ----------------------------------------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-lg) var(--sp-xl);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  gap: var(--sp-xl);
  flex-wrap: wrap;
}
.site-header .logo-link {
  display: inline-flex;
  align-items: center;
}
.site-header .logo-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
  border-radius: 2px;
}
.site-header .logo {
  height: 40px;
  width: auto;
}

/* --- Tab Navigation --------------------------------------- */
.tabs {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}
.tabs::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 600px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(180deg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 610 377'%3E%3Cpath d='M 610 0 A 377 377 0 0 1 233 377 A 233 233 0 0 1 0 144 A 144 144 0 0 1 144 0 A 89 89 0 0 1 233 89 A 55 55 0 0 1 178 144 A 34 34 0 0 1 144 110 A 21 21 0 0 1 165 89 A 13 13 0 0 1 178 102 A 8 8 0 0 1 170 110 A 5 5 0 0 1 165 105 A 3 3 0 0 1 168 102 A 2 2 0 0 1 170 104' fill='none' stroke='%23c48a3a' stroke-width='1.5' opacity='0.06'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  pointer-events: none;
  z-index: 0;
}
.tabs > * {
  position: relative;
  z-index: 1;
}

.tab-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-xl);
  padding: 0;
}

.tab-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.tab-label {
  display: inline-block;
  padding: var(--sp-md) var(--sp-xs);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .2s, border-color .2s;
  user-select: none;
}
.tab-label:hover {
  color: var(--text);
}
/* Active tab label – driven by .active class set via change listener */
.tab-label.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-label:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Tab panels – hidden by default, shown via :checked sibling */
.tab-panel {
  display: none;
  flex: 1;
}
#tab-gallery:checked ~ #panel-gallery,
#tab-builds:checked  ~ #panel-builds,
#tab-about:checked   ~ #panel-about {
  display: block;
}

/* --- Shared content container ----------------------------- */
.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-2xl) var(--sp-xl);
  width: 100%;
}

/* --- Photo Gallery ---------------------------------------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: var(--sp-xl);
}

.gallery-tile {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.gallery-tile:hover,
.gallery-tile:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 21px rgba(0,0,0,.4);
}

.gallery-tile-img-wrap {
  aspect-ratio: 2.618 / 1;
  overflow: hidden;
}
.gallery-tile-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform .3s;
}
.gallery-tile:hover .gallery-tile-img-wrap img {
  transform: scale(1.03);
}

.gallery-tile-info {
  padding: var(--sp-md) var(--sp-lg);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.gallery-tile-model {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text);
}
.gallery-tile-serial {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.gallery-tile-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.gallery-tile-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
  border-radius: 4px;
}

/* --- Lightbox --------------------------------------------- */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 900;
  background: rgba(10,8,5,.92);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.lightbox.is-open {
  display: flex;
}

.lightbox-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-md) var(--sp-xl);
  z-index: 2;
}
.lightbox-title {
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.lightbox-counter {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.lightbox-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s;
}
.lightbox-close:hover,
.lightbox-close:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--sp-3xl) var(--sp-2xl);
  position: relative;
}
.lightbox-stage img {
  max-height: 80vh;
  max-width: 90vw;
  object-fit: contain;
  border-radius: 2px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(43,35,24,.7);
  border: 1px solid var(--border);
  color: var(--text);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, background .2s;
  z-index: 2;
}
.lightbox-nav:hover,
.lightbox-nav:focus-visible {
  border-color: var(--accent);
  background: rgba(43,35,24,.95);
  outline: none;
}
.lightbox-prev { left: var(--sp-lg); }
.lightbox-next { right: var(--sp-lg); }

.lightbox-nav[hidden] { display: none; }

/* --- In Progress Builds ----------------------------------- */
.build-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.build-hero {
  width: 100%;
  aspect-ratio: 1.618 / 1;
  overflow: hidden;
  position: relative;
}
.build-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.build-status {
  position: absolute;
  top: var(--sp-md);
  left: var(--sp-md);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(12, 10, 7, 0.85);
  padding: var(--sp-sm) var(--sp-lg);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  z-index: 1;
}

.build-model {
  font-size: 1.3rem;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
}

.build-price {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--text);
}

.build-specs {
  padding: var(--sp-xl);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--sp-xl);
}
.build-specs-heading {
  grid-column: 1 / -1;
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text);
  padding-bottom: var(--sp-md);
  border-bottom: 2px solid var(--accent);
  margin-bottom: 0;
}

.spec-group h2,
.spec-group h3 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-md);
  padding-bottom: var(--sp-xs);
  border-bottom: 1px solid var(--border);
}
.spec-group dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-xs) var(--sp-lg);
}
.spec-group dt {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.spec-group dd {
  font-size: 0.85rem;
  color: var(--text);
}

/* --- About Section ---------------------------------------- */
.about-intro {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: var(--sp-2xl);
  line-height: 1.8;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-xl);
}

.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: var(--sp-xl);
}
.about-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-lg);
}
.about-card p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* --- Footer ----------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  padding: var(--sp-lg) var(--sp-xl);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-lg);
  flex-wrap: wrap;
}
.site-footer .logo-link {
  display: inline-flex;
}
.site-footer .logo-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 4px;
  border-radius: 2px;
}
.site-footer .logo {
  height: 28px;
  width: auto;
  opacity: .6;
  transition: opacity .2s;
}
.site-footer .logo-link:hover .logo {
  opacity: 1;
}

.footer-links {
  display: flex;
  gap: var(--sp-lg);
  align-items: center;
  flex: 1;
  justify-content: center;
}
.footer-links a {
  color: var(--text-muted);
  transition: color .2s;
}
.footer-links a:hover {
  color: var(--accent);
}
.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}
.footer-links svg {
  display: block;
}

.footer-slot {
  flex: 1;
  display: flex;
}
.footer-slot--end {
  justify-content: flex-end;
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-align: right;
  text-transform: lowercase;
}

/* --- Coming Soon Page ------------------------------------- */
.coming-soon {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-3xl) var(--sp-xl);
  gap: var(--sp-lg);
  position: relative;
  overflow: visible;
}
.coming-soon::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 600px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(180deg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 610 377'%3E%3Cpath d='M 610 0 A 377 377 0 0 1 233 377 A 233 233 0 0 1 0 144 A 144 144 0 0 1 144 0 A 89 89 0 0 1 233 89 A 55 55 0 0 1 178 144 A 34 34 0 0 1 144 110 A 21 21 0 0 1 165 89 A 13 13 0 0 1 178 102 A 8 8 0 0 1 170 110 A 5 5 0 0 1 165 105 A 3 3 0 0 1 168 102 A 2 2 0 0 1 170 104' fill='none' stroke='%23c48a3a' stroke-width='1.5' opacity='0.06'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  pointer-events: none;
  z-index: 0;
}
.coming-soon > * {
  position: relative;
  z-index: 1;
}
.coming-soon h1 {
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
}
.coming-soon p {
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.8;
}
.coming-soon-card {
  margin-top: var(--sp-2xl);
  max-width: 540px;
}

/* --- Models Section (on Coming Soon page) ----------------- */
.models-section {
  margin-top: var(--sp-2xl);
  width: 100%;
  max-width: 600px;
}
.models-section h2 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-lg);
  text-align: center;
}
.models-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-md);
}
.models-list li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: var(--sp-md) var(--sp-lg);
}
.models-list .model-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 1px;
}
.models-list .model-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: var(--sp-xs);
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 768px) {
  .tab-bar {
    gap: var(--sp-lg);
  }
  .tab-label {
    font-size: 0.75rem;
    letter-spacing: 1.5px;
  }
  .gallery-grid {
    grid-template-columns: 1fr;
  }
  .content {
    padding: var(--sp-xl) var(--sp-lg);
  }
  .build-specs {
    grid-template-columns: 1fr;
  }
  .lightbox-nav {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
  .lightbox-prev { left: var(--sp-sm); }
  .lightbox-next { right: var(--sp-sm); }
  .lightbox-stage {
    padding: var(--sp-2xl) var(--sp-lg);
  }
  .spec-group dl {
    grid-template-columns: 1fr;
  }
  .spec-group dt {
    white-space: normal;
    color: var(--text-muted);
    margin-top: var(--sp-sm);
  }
  .spec-group dt:first-of-type {
    margin-top: 0;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: var(--sp-md) var(--sp-lg);
    flex-direction: column;
    align-items: center;
    gap: var(--sp-md);
  }
  .site-header .logo {
    height: 32px;
  }
  .tab-bar {
    gap: var(--sp-md);
    justify-content: center;
    width: 100%;
  }
  .gallery-tile-info {
    gap: var(--sp-sm);
  }
  .gallery-tile-serial {
    white-space: nowrap;
  }
}

/* --- Focus Visible (global) ------------------------------- */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
/* Fallback for browsers without :focus-visible */
:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* Landscape phones – give lightbox more room */
@media (max-height: 500px) and (orientation: landscape) {
  .lightbox-stage {
    padding: var(--sp-lg) var(--sp-2xl);
  }
  .lightbox-stage img {
    max-height: 90vh;
  }
  .lightbox-header {
    padding: var(--sp-xs) var(--sp-lg);
  }
}

/* Reduce motion if requested */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
