/* assets/css/layout.css */

/* ── NAV ── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--nav-shadow);
  z-index: 1000;
  transition: background var(--transition), box-shadow var(--transition);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-logo img {
  height: 32px;
  width: auto;
  /* never let the logo compress — it has a fixed intrinsic size */
  flex-shrink: 0;
  min-width: 0;
}

.nav-logo {
  flex-shrink: 0;
}

/* Dark mode logo swap */
.logo-light { display: block; }
.logo-dark  { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark  { display: block; }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.nav-links a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition);
  position: relative;
  padding-bottom: 2px;
}

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

.nav-links a.active {
  color: var(--color-orange);
  font-weight: 600;
}

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-orange);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ── NAV CHEVRON ── */
.nav-chevron {
  display: inline-block;
  vertical-align: middle;
  margin-left: 3px;
  transition: transform var(--transition);
  flex-shrink: 0;
}

/* ── NAV SUBMENU ── */
.nav-has-sub {
  position: relative;
}

/* Desktop: show submenu on hover */
@media (min-width: 961px) {
  .nav-has-sub > a {
    display: flex;
    align-items: center;
    gap: 2px;
  }

  .nav-sub {
    position: absolute;
    /* Sit flush with the nav bottom; use padding-top as invisible bridge */
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding-top: 10px; /* bridge: mouse can travel here without losing hover */
    min-width: 200px;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  /* Inner box so padding-top isn't visible */
  .nav-sub::before {
    content: '';
    display: block;
    position: absolute;
    inset: 10px 0 0 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: -1;
  }

  .nav-sub li {
    list-style: none;
  }

  .nav-has-sub:hover .nav-sub,
  .nav-has-sub:focus-within .nav-sub {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
  }

  .nav-has-sub:hover .nav-chevron,
  .nav-has-sub:focus-within .nav-chevron {
    transform: rotate(180deg);
  }

  .nav-sub a {
    display: block;
    padding: 0.55rem 1rem;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color var(--transition), background var(--transition);
  }

  .nav-sub li:first-child a { border-radius: var(--border-radius) var(--border-radius) 0 0; }
  .nav-sub li:last-child a  { border-radius: 0 0 var(--border-radius) var(--border-radius); }

  .nav-sub a:hover {
    color: var(--color-orange);
    background: var(--bg-secondary);
  }

  /* RTL: open submenu to the right */
  html[dir="rtl"] .nav-sub {
    left: auto;
    right: 50%;
    transform: translateX(50%) translateY(-4px);
  }

  html[dir="rtl"] .nav-has-sub:hover .nav-sub,
  html[dir="rtl"] .nav-has-sub:focus-within .nav-sub {
    transform: translateX(50%) translateY(0);
  }
}

/* Mobile: submenu opens inline below parent */
@media (max-width: 960px) {
  .nav-has-sub > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .nav-sub {
    display: none;
    list-style: none;
    padding: 0 0 0.25rem 0.75rem;
    background: none;
    border: none;
    box-shadow: none;
  }

  .nav-has-sub.mobile-open > .nav-sub {
    display: block;
  }

  .nav-has-sub.mobile-open .nav-chevron {
    transform: rotate(180deg);
  }

  .nav-sub a {
    display: block;
    padding: 0.45rem 0.75rem;
    font-size: var(--text-sm);
    color: var(--text-muted);
    border-radius: var(--border-radius);
    transition: color var(--transition);
  }

  .nav-sub a:hover {
    color: var(--color-orange);
  }
}

/* ── NAV LANGUAGE DROPDOWN ── */
.nav-lang {
  position: relative;
}

.nav-lang-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all var(--transition);
  padding: 0;
}

.nav-lang-btn:hover,
.nav-lang-btn[aria-expanded="true"] {
  border-color: var(--color-orange);
  color: var(--color-orange);
}

.nav-lang-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 140px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  list-style: none;
  padding: 0.35rem 0;
  z-index: 1100;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.nav-lang-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-lang-opt {
  display: block;
  width: 100%;
  padding: 0.55rem 1rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav-lang-opt:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.nav-lang-opt.active {
  color: var(--color-orange);
  font-weight: 700;
}

/* RTL: dropdown opens left-aligned */
[dir="rtl"] .nav-lang-dropdown {
  right: auto;
  left: 0;
}

[dir="rtl"] .nav-lang-opt {
  text-align: right;
}

/* Theme toggle button */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition);
  color: var(--text-primary);
}

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

/* Mobile menu toggle */
.nav-burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  background: none;
  border: none;
}

.nav-burger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ── PAGE SECTION TABS (shared across about / factory / why-frp) ── */
.page-tabs-wrap {
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.page-tabs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

.page-tabs::-webkit-scrollbar {
  display: none;
}

.page-tab {
  display: inline-block;
  padding: 1rem 1.25rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.page-tab:hover {
  color: var(--color-orange);
  border-bottom-color: var(--color-orange);
}

.page-tab.active {
  color: var(--color-orange);
  border-bottom-color: var(--color-orange);
}

/* Offset anchor targets to account for sticky nav + tabs */
.page-tabs-wrap ~ * [id],
section[id] {
  scroll-margin-top: calc(var(--nav-height) + 56px);
}

@media (max-width: 768px) {
  .page-tab {
    padding: 0.85rem 0.9rem;
    font-size: 0.78rem;
  }
}

/* ── FOOTER ── */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: var(--space-lg) 0 var(--space-md);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.footer-brand img {
  height: 45px;
  width: auto;
  margin-bottom: var(--space-sm);
}

/* Footer is always dark — always show dark logo */
.footer-brand .logo-light { display: none; }
.footer-brand .logo-dark  { display: block; }

.footer-brand p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.7;
  max-width: 320px;
}

.footer-col h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.footer-col ul li {
  margin-bottom: 0.5rem;
}

.footer-col ul li a {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  transition: color var(--transition);
}

.footer-col ul li a:hover {
  color: var(--color-orange);
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ── RESPONSIVE ── */

/* Quote button sizing across breakpoints */
.nav-quote-btn {
  padding: 0.5rem 1.25rem;
  font-size: var(--text-sm);
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .nav-quote-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.75rem;
  }
}

@media (max-width: 960px) {
  .nav-quote-btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.68rem;
    letter-spacing: 0;
  }
}

@media (max-width: 420px) {
  /* On very small phones clip the label to just "Quote" */
  .nav-quote-btn .nav-quote-full { display: none; }
  .nav-quote-btn .nav-quote-short { display: inline; }
}

@media (min-width: 421px) {
  .nav-quote-btn .nav-quote-short { display: none; }
}

@media (max-width: 960px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.95);
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-direction: column;
    padding: var(--space-md);
    gap: 0.25rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  [data-theme="dark"] .nav-links {
    background: rgba(15,15,15,0.97);
    border-bottom-color: rgba(255,255,255,0.08);
  }

  .nav-links.open {
    display: flex;
  }

  /* Mobile nav link items — orange glow on hover */
  .nav-links li {
    border-radius: var(--border-radius);
    overflow: hidden;
  }

  .nav-links a {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: var(--border-radius);
    transition: color var(--transition), background var(--transition), box-shadow var(--transition);
  }

  .nav-links a:hover {
    color: var(--color-orange);
    background: transparent;
  }

  .nav-links a.active {
    color: var(--color-orange);
    background: transparent;
  }

  .nav-burger {
    display: flex;
  }
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .footer-bottom {
    flex-direction: column;
    gap: var(--space-xs);
    text-align: center;
  }
}

/* ── RTL NAV ── */
html[dir="rtl"] .nav-inner {
  flex-direction: row-reverse;
}

html[dir="rtl"] .nav-actions {
  flex-direction: row-reverse;
}

/* Desktop RTL: links flow right-to-left */
@media (min-width: 961px) {
  html[dir="rtl"] .nav-links {
    flex-direction: row-reverse;
  }
}

/* Mobile RTL: keep vertical column, just align text right */
@media (max-width: 960px) {
  html[dir="rtl"] .nav-links {
    flex-direction: column;
    text-align: right;
  }
}

/* ── RTL FOOTER ── */
[dir="rtl"] .footer-grid {
  direction: rtl;
}

[dir="rtl"] .footer-bottom {
  flex-direction: row-reverse;
}

/* ── FOOTER ALWAYS-DARK ── */
.footer {
  background: #111111;
  border-top: 1px solid #222;
}

[data-theme="dark"] .footer {
  background: #0a0a0a;
  border-top: 1px solid #1e1e1e;
}

.footer-col h4 {
  color: #888;
}

.footer-col ul li a {
  color: #666;
}

.footer-col ul li a:hover {
  color: var(--color-orange);
}

.footer-bottom {
  color: #555;
  border-top-color: #222;
}

.footer-brand p {
  color: #666;
}
