/* ── SHARED NAV ─────────────────────────────────────────
   One nav for every page. Load it after the page's own <style>.
   Sizes are in px, not rem: a page that sets its own root font-size (the pdf editor uses 14px)
   would otherwise shrink the nav. */
:root { --nav-h: 58px; }

.nav {
  --nav-pad: clamp(16px, 5vw, 64px);
  --nav-bg: rgba(13,13,11,.94);
  --nav-solid: #0d0d0b;
  --nav-border: #2a2a24;
  --nav-surface: #1c1c18;
  --nav-text: #f1ece2;
  --nav-muted: #a6a091;
  --nav-accent: #ff6b47;
  --nav-accent-dim: rgba(255,107,71,.12);

  /* 4000 keeps the nav above the pdf editor's tour and splash overlays, as before */
  position: fixed; top: 0; left: 0; right: 0; z-index: 4000;
  height: var(--nav-h);
  background: var(--nav-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--nav-border);
  display: flex; align-items: center;
  /* --nav-sbw: scrollbar width on pages without one (set in includes/nav.php), so the right side never shifts */
  padding: 0 calc(var(--nav-pad) + var(--nav-sbw, 0px)) 0 var(--nav-pad);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
:root[data-theme="light"] .nav {
  --nav-bg: rgba(244,240,230,.94);
  --nav-solid: #f4f0e6;
  --nav-border: #d3ccb8;
  --nav-surface: #ebe5d6;
  --nav-text: #1c1a14;
  --nav-muted: #5b5646;
  --nav-accent: #c93a1a;
  --nav-accent-dim: rgba(201,58,26,.1);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .nav {
    --nav-bg: rgba(244,240,230,.94);
    --nav-solid: #f4f0e6;
    --nav-border: #d3ccb8;
    --nav-surface: #ebe5d6;
    --nav-text: #1c1a14;
    --nav-muted: #5b5646;
    --nav-accent: #c93a1a;
  }
}

.nav a { color: inherit; text-decoration: none; }

.nav-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 15.2px; font-weight: 700; color: var(--nav-text);
  letter-spacing: -.02em; margin-right: 28px; white-space: nowrap; flex-shrink: 0;
}
.nav .logo {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  object-fit: contain;
}
.nav .brand-dot { color: var(--nav-accent); }

/* Desktop links */
.nav-links { display: flex; gap: 2px; flex: 1; align-items: center; min-width: 0; }
.nav-a {
  display: flex; align-items: center; position: relative;
  padding: 5px 13px; border-radius: 8px;
  font-size: 13.84px; font-weight: 500; color: var(--nav-muted);
  transition: color .14s, background .14s; white-space: nowrap;
}
.nav-a:hover { color: var(--nav-text); background: var(--nav-surface); }
.nav-a.active { color: var(--nav-accent); background: var(--nav-accent-dim); }
.nav-sep { width: 1px; height: 24px; background: var(--nav-border); margin: 0 4px; flex-shrink: 0; }

/* Theme toggle (sun / moon switch) */
.nav .theme-toggle-wrapper { margin-left: auto; display: flex; align-items: center; flex-shrink: 0; position: relative; }
/* Visually hidden rather than display:none so keyboard users can reach the switch */
.nav .toggle-checkbox {
  position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none;
}
.nav .toggle-checkbox:focus-visible + .toggle-switch { outline: 2px solid var(--nav-accent); outline-offset: 3px; }
.nav .toggle-switch {
  position: relative; width: 60px; height: 30px; border-radius: 50px; cursor: pointer; overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,.2), inset 0 1px 2px rgba(255,255,255,.15);
  transition: background .6s cubic-bezier(.4,0,.2,1);
  background: linear-gradient(to bottom, #4ea3e8 0%, #a1d2f7 55%, #ffd494 85%, #ffb076 100%);
}
.nav .clouds {
  position: absolute; width: 100%; height: 100%; top: 0; left: 0;
  transition: opacity .5s ease, transform .5s ease; opacity: 1; transform: translateY(0);
}
.nav .cloud-back, .nav .cloud-front { position: absolute; background: #fff; border-radius: 50px; }
.nav .cloud-back { width: 24px; height: 9px; bottom: 3px; right: 8px; opacity: .6; }
.nav .cloud-front { width: 20px; height: 7px; bottom: 1px; right: 14px; }
.nav .stars {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0;
  transform: translateY(-5px); transition: opacity .6s ease, transform .6s ease;
}
.nav .star { position: absolute; background: #fff; border-radius: 50%; box-shadow: 0 0 2px #fff; }
.nav .star:nth-child(1) { top: 8px; left: 11px; width: 2px; height: 2px; }
.nav .star:nth-child(2) { top: 17px; left: 7px; width: 1px; height: 1px; }
.nav .star:nth-child(3) { top: 10px; left: 20px; width: 2px; height: 2px; }
.nav .star:nth-child(4) { top: 22px; left: 16px; width: 1px; height: 1px; }
.nav .star:nth-child(5) { top: 6px; left: 28px; width: 1px; height: 1px; }
.nav .sun, .nav .moon {
  position: absolute; width: 24px; height: 24px; border-radius: 50%; top: 3px;
  transition: transform .7s cubic-bezier(.68,-.4,.27,1.35), opacity .4s ease;
}
.nav .sun {
  left: 4px;
  background: radial-gradient(circle at 35% 35%, #fff176, #fbc02d 70%, #f57f17 100%);
  box-shadow: 0 0 8px #ffeb3b, inset -1px -1px 3px rgba(0,0,0,.15);
  transform: translate(0,0); opacity: 1;
}
.nav .moon {
  right: 4px;
  background: radial-gradient(circle at 35% 35%, #fff, #e0e0e0 70%, #bdbdbd 100%);
  box-shadow: 0 0 6px rgba(255,255,255,.4), inset -1px -1px 2px rgba(0,0,0,.2);
  transform: translate(0,35px) rotate(-40deg); opacity: 0;
}
.nav .crater { position: absolute; background: #9e9e9e; border-radius: 50%; box-shadow: inset 1px 1px 1px rgba(0,0,0,.35); opacity: .5; }
.nav .crater:nth-child(1) { top: 5px; left: 6px; width: 5px; height: 5px; }
.nav .crater:nth-child(2) { top: 13px; left: 11px; width: 4px; height: 4px; }
.nav .crater:nth-child(3) { top: 14px; left: 5px; width: 3px; height: 3px; }
.nav .toggle-checkbox:checked + .toggle-switch { background: linear-gradient(to bottom, #090b14 0%, #171b30 60%, #292d4b 100%); }
.nav .toggle-checkbox:checked + .toggle-switch .sun { transform: translate(0,35px) rotate(40deg); opacity: 0; }
.nav .toggle-checkbox:checked + .toggle-switch .moon { transform: translate(0,0) rotate(0deg); opacity: 1; }
.nav .toggle-checkbox:checked + .toggle-switch .clouds { opacity: 0; transform: translateY(8px); }
.nav .toggle-checkbox:checked + .toggle-switch .stars { opacity: 1; transform: translateY(0); }

/* Hover / focus tooltips. nav.js adds .has-tip and the .nav-tip bubble to each control. */
.nav .has-tip { position: relative; }
.nav .nav-tip {
  position: absolute; top: calc(100% + 12px); left: 50%;
  z-index: 10; width: max-content; max-width: 240px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--nav-surface); border: 1px solid var(--nav-border);
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
  color: var(--nav-muted); font-size: 12.16px; font-weight: 400; line-height: 1.45;
  text-align: left; white-space: normal; letter-spacing: 0;
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%, -4px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
/* Small arrow pointing up at the control */
.nav .nav-tip::before {
  content: ""; position: absolute; top: -5px; left: 50%; width: 9px; height: 9px;
  background: var(--nav-surface); border-left: 1px solid var(--nav-border); border-top: 1px solid var(--nav-border);
  transform: translateX(-50%) rotate(45deg);
}
.nav .nav-tip strong {
  display: block; margin-bottom: 2px;
  color: var(--nav-text); font-size: 12.8px; font-weight: 600; letter-spacing: -.01em;
}
/* Right-edge control: anchor the bubble to the right so it stays inside the viewport */
.nav .nav-tip.is-end { left: auto; right: 0; transform: translate(0, -4px); }
.nav .nav-tip.is-end::before { left: auto; right: 22px; transform: rotate(45deg); }

.nav .has-tip:focus-visible > .nav-tip,
.nav .has-tip:has(:focus-visible) > .nav-tip {
  opacity: 1; visibility: visible; transform: translate(-50%, 0);
}
.nav .has-tip.is-end:focus-visible > .nav-tip,
.nav .has-tip.is-end:has(:focus-visible) > .nav-tip { transform: translate(0, 0); }
/* Touch tablets often claim hover support and fire hover on tap, so require a fine pointer too */
@media (hover: hover) and (pointer: fine) {
  .nav .has-tip:hover > .nav-tip {
    opacity: 1; visibility: visible; transform: translate(-50%, 0);
    transition-delay: .15s;
  }
  .nav .has-tip.is-end:hover > .nav-tip { transform: translate(0, 0); }
}
.nav.nav-touch .nav-tip { display: none; }
@media (prefers-reduced-motion: reduce) {
  .nav .nav-tip { transition: none; }
}

/* Hamburger + phone menu (hidden on desktop) */
.nav-burger {
  display: none; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-left: 10px; padding: 0; flex-shrink: 0;
  border-radius: 10px; border: 1px solid var(--nav-border);
  background: var(--nav-surface); color: var(--nav-text); cursor: pointer;
}
.nav-burger-bars { position: relative; width: 18px; height: 14px; display: block; }
.nav-burger-bars span {
  position: absolute; left: 0; right: 0; height: 2px; border-radius: 2px; background: currentColor;
  transition: transform .2s ease, opacity .2s ease, top .2s ease;
}
.nav-burger-bars span:nth-child(1) { top: 0; }
.nav-burger-bars span:nth-child(2) { top: 6px; }
.nav-burger-bars span:nth-child(3) { top: 12px; }
.nav.is-open .nav-burger-bars span:nth-child(1) { top: 6px; transform: rotate(45deg); }
.nav.is-open .nav-burger-bars span:nth-child(2) { opacity: 0; }
.nav.is-open .nav-burger-bars span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

.nav-menu {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px;
  padding: 14px var(--nav-pad) 18px;
  background: var(--nav-solid);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: 0 16px 32px rgba(0,0,0,.25);
}
.nav.is-open .nav-menu { display: grid; }
.nav-menu-col { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nav-menu-head {
  padding: 6px 8px; font-size: 12.8px; font-weight: 700; color: var(--nav-text);
  letter-spacing: -.01em; white-space: nowrap;
}
.nav-menu-head.active { color: var(--nav-accent); }
.nav-menu-item {
  padding: 6px 8px; border-radius: 8px; font-size: 13.44px; font-weight: 500; color: var(--nav-muted);
  white-space: nowrap;
}
.nav-menu-item:hover { color: var(--nav-text); background: var(--nav-surface); }
.nav-menu-item.active { color: var(--nav-accent); background: var(--nav-accent-dim); }
.nav-burger:focus-visible, .nav-a:focus-visible, .nav-menu a:focus-visible {
  outline: 2px solid var(--nav-accent); outline-offset: 2px;
}

/* Phone: burger replaces the link row */
/* The full link row (7 items incl. "PDF Editor" and "BG Remove") needs real room —
   below this width it collides with the theme toggle instead of wrapping, so the
   burger menu takes over well before that happens. */
@media (max-width: 1250px) {
  .nav-brand { margin-right: auto; }
  .nav-links { display: none; }
  .nav-burger { display: inline-flex; }
  .nav .theme-toggle-wrapper { margin-left: auto; }
  .nav-tag { display: none; }
}
@media (max-width: 360px) {
  .nav-brand { font-size: 14.08px; }
  .nav .logo { width: 30px; height: 30px; border-radius: 6px; }
  .nav-burger { margin-left: 8px; }
}

/* Short pages: keep the footer at the bottom of the window, not under the content. */
body:has(> footer:not(#statusbar)) { display: flex; flex-direction: column; min-height: 100vh; }
body > footer:not(#statusbar) { margin-top: auto; }

/* ── Tool page title ──────────────────────────────────────
   One title style for every converter / editor page (image, audio, video, compress, resize, BG remove).
   Pages must not restyle .header themselves; .wrap > raises specificity above their inline rules. */
.wrap > .header { text-align: center; margin-bottom: 18px; }
.wrap > .header h1 {
  font-family: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  font-weight: 400; letter-spacing: -.02em; line-height: 1.15;
  font-size: clamp(1.5rem, 4.6vw, 2.5rem);
}
.wrap > .header h1 span { color: var(--accent); }
.wrap > .header p { color: var(--muted); font-size: .95rem; margin-top: 6px; }
