/* ==========================================================================
   mobile.css – Handy & Tablet Layer für andreasdavid.at
   Wird NACH styles.css eingebunden:
     <link rel="stylesheet" href="styles.css">
     <link rel="stylesheet" href="mobile.css">
   Additiv – styles.css bleibt unverändert.
   ========================================================================== */

:root {
  /* Eingangswert: feste Höhe der Logo-Zeile */
  --nav-row-h: 58px;
  /* Ausgangswert: gemessene Gesamthöhe des Headers, gesetzt von nav.js.
     Speist ausschließlich sticky-Offsets – niemals eine Header-Höhe. */
  --header-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* --- 0. Globale Guards ---------------------------------------------------- */

html,
body {
  overflow-x: clip;
}

/* iOS repaintet background-attachment:fixed bei jedem Scroll-Frame → Ruckeln */
@media (max-width: 1200px), (hover: none) {
  body {
    background-attachment: scroll;
  }
}

/* Sticky Header verdeckt Anchor-Ziele bei scroll-behavior:smooth */
section[id],
[id^="hotspot-"],
.flight-phase[id] {
  scroll-margin-top: calc(var(--header-h) + 12px);
}

/* iOS zoomt bei Fokus auf Inputs < 16px */
@media (max-width: 1200px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* --- 1. Header: kompakt + Burger ----------------------------------------- */

.nav-toggle,
.nav-drawer,
.section-nav,
header .nav-tabs {
  display: none;
}

@media (max-width: 1200px) {
  header {
    border-bottom-width: 2px;
  }

  .nav {
    min-height: var(--nav-row-h);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0;
  }

  .logo {
    gap: 0.65rem;
    min-width: 0;
  }

  .logo img {
    height: 34px;
  }

  .logo-text {
    font-size: 1.05rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Desktop-Nav & Header-Code-Feld raus – ersetzt durch Drawer/Tabs.
     Nur wenn nav.js läuft: ohne JS bleibt die bestehende Nav benutzbar. */
  html.js-mobilenav header .nav-links,
  html.js-mobilenav header .code-widget {
    display: none;
  }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 48px;
    height: 48px;
    padding: 0 12px;
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
  }

  .nav-toggle span {
    display: block;
    height: 2px;
    background: var(--accent-2);
    transition: transform 0.2s, opacity 0.2s;
  }

  .nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .nav-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

/* --- 2. Drawer (Vollbild-Overlay) ---------------------------------------- */

@media (max-width: 1200px) {
  .nav-drawer {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    z-index: 999;
    background: rgba(6, 8, 12, 0.97);
    backdrop-filter: blur(10px);
    padding: 1.25rem 1rem calc(2rem + var(--safe-b));
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
  }

  .nav-drawer.open {
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .nav-drawer .drawer-label {
    font-family: ui-monospace, monospace;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    color: var(--accent-2);
    margin: 0 0 0.75rem;
  }

  .nav-drawer .drawer-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--border);
    margin-bottom: 1.75rem;
  }

  .nav-drawer .drawer-links a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 56px;
    padding: 0 1.1rem;
    background: var(--bg);
    color: var(--text);
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 1.25rem;
  }

  .nav-drawer .drawer-links a .idx {
    font-family: ui-monospace, monospace;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: var(--muted);
  }

  .nav-drawer .drawer-links a[aria-current="page"] {
    background: var(--accent-2);
    color: #04070c;
  }

  .nav-drawer .drawer-links a[aria-current="page"] .idx {
    color: rgba(4, 7, 12, 0.6);
  }

  .nav-drawer .drawer-code {
    display: flex;
    gap: 2px;
    margin-bottom: 1.5rem;
  }

  .nav-drawer .drawer-code input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'Barlow Condensed', sans-serif;
    text-transform: uppercase;
    padding: 0.8rem 1rem;
    outline: none;
  }

  .nav-drawer .drawer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-size: 0.85rem;
  }

  .nav-drawer .drawer-meta a {
    color: var(--muted);
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  body.nav-open {
    overflow: hidden;
  }
}

/* --- 3. Tablet: Tab-Leiste als zweite Header-Zeile ------------------------ */

@media (min-width: 641px) and (max-width: 1200px) {
  :root {
    --nav-row-h: 68px;
    /* Fallback: Logo-Zeile + Tab-Zeile + Border */
    --header-h: 116px;
  }

  header .nav-tabs {
    display: flex;
    gap: 2px;
    background: var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }

  header .nav-tabs::-webkit-scrollbar {
    display: none;
  }

  header .nav-tabs a {
    flex: 1 0 auto;
    scroll-snap-align: start;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 1.4rem;
    background: rgba(6, 8, 12, 0.85);
    color: var(--muted);
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.95rem;
    clip-path: none;
  }

  header .nav-tabs a[aria-current="page"] {
    background: var(--accent-2);
    color: #04070c;
  }

  /* Auf dem Tablet (641–1200px) ersetzt die Tab-Zeile den Burger */
  .nav-toggle {
    display: none;
  }
}

/* --- 4. Handy: Safe-Area (Navigation läuft ausschließlich über den Hamburger-Drawer) --- */

@media (max-width: 640px) {
  .nav-drawer {
    bottom: 0;
  }
}

/* --- 5. Sektions-Navigation innerhalb langer Seiten ---------------------- */

@media (max-width: 1200px) {
  .section-nav {
    display: flex;
    position: sticky;
    top: var(--header-h);
    z-index: 900;
    gap: 2px;
    padding: 0;
    margin: 0;
    background: var(--border);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .section-nav::-webkit-scrollbar {
    display: none;
  }

  .section-nav a {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1rem;
    background: rgba(6, 8, 12, 0.95);
    color: var(--muted);
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  .section-nav a.active {
    color: #04070c;
    background: var(--accent-2);
  }
}

/* --- 6. Typo & Abstände -------------------------------------------------- */

@media (max-width: 640px) {
  section {
    padding: 3rem 0;
  }

  .page-hero {
    padding: 2.5rem 0 2.25rem;
  }

  .section-title {
    font-size: 1.65rem;
  }

  .section-text {
    margin-bottom: 1.5rem;
  }

  .card,
  .dashboard-panel,
  .hybrid-card {
    padding: 1.25rem;
  }

  .hero h1 {
    font-size: 2rem;
    line-height: 1.08;
  }

  .hero p {
    font-size: 1rem;
  }
}

/* --- 7. Buttons & Formulare ---------------------------------------------- */

@media (max-width: 640px) {
  .btn {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    /* Schräge Kante würde bei voller Breite Text anschneiden → flacher */
    clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  }

  .hero-buttons,
  .discord-panel {
    display: grid;
    gap: 0.6rem;
  }

  .hero-buttons .btn {
    width: 100%;
  }

  .code-form,
  .new-gallery-form {
    display: grid;
    gap: 0.6rem;
    max-width: none;
  }

  .code-form input,
  .new-gallery-form input {
    min-width: 0;
    width: 100%;
  }

  .contact-form {
    max-width: none;
  }

  .social-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 2px;
  }

  .social-link {
    justify-content: center;
    min-height: 48px;
  }
}

/* Code-Band unter dem Header (ersetzt das Header-Widget) */
.code-band {
  display: none;
}

@media (max-width: 1200px) {
  .code-band {
    display: block;
    background: rgba(6, 8, 12, 0.92);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 0;
  }

  .code-band form {
    display: flex;
    gap: 2px;
  }

  .code-band input {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: 'Barlow Condensed', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.7rem 0.9rem;
    outline: none;
  }

  .code-band input:focus {
    border-color: var(--accent-2);
  }

  .code-band .btn {
    min-height: 46px;
  }
}

/* --- 8. Intro-Logo: kleinere Bühne auf Handy/Tablet --------------------- */

@media (max-width: 1200px) {
  .hero-intro {
    min-height: auto;
    padding: 2.5rem 0 3rem;
  }

  .intro-logo-svg {
    width: min(58vw, 240px);
  }
}

/* --- 9. Simracing: Tabelle, Hotspots, Clips ----------------------------- */

/* .feature-cards hatte in styles.css überhaupt kein Regelwerk */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  background: var(--border);
}

.feature-card {
  background: var(--bg);
  padding: 1.5rem;
}

.feature-card h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.feature-card p {
  color: var(--muted);
}

@media (max-width: 1200px) {
  .feature-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .feature-cards {
    grid-template-columns: 1fr;
  }
}

/* Tabelle: Tablet scrollt horizontal, Handy stapelt zu Karten */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
  .laptime-table {
    display: block;
    background: var(--border);
  }

  .laptime-table thead {
    display: block;
  }

  .laptime-table thead tr {
    display: flex;
    gap: 2px;
    background: var(--border);
  }

  .laptime-table thead th {
    flex: 1;
    padding: 0;
    border: none;
    background: var(--bg);
  }

  .laptime-table thead th button {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  .laptime-table tbody {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
  }

  .laptime-table tbody tr {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 1rem;
    background: var(--bg);
    padding: 1rem 1.1rem;
  }

  .laptime-table tbody td {
    border: none;
    padding: 0;
    text-align: right;
  }

  .laptime-table tbody td::before {
    content: attr(data-label);
    float: left;
    font-family: 'Barlow Condensed', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
  }

  .laptime-table tbody td:first-child {
    grid-column: 1 / -1;
    text-align: left;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 1.15rem;
    margin-bottom: 0.35rem;
  }

  .laptime-table tbody td:first-child::before {
    display: none;
  }
}

/* Hotspot-Karte: 220px absolut positioniert ragt aus dem Viewport */
@media (max-width: 1200px) {
  .hotspot {
    width: 44px;
    height: 44px;
    font-size: 1.05rem;
  }

  .hotspot-card {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto !important;
    width: auto;
    transform: none;
    padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-b));
    border: none;
    border-top: 2px solid var(--accent-2);
    z-index: 1002;
  }
}

@media (max-width: 640px) {
  .hotspot-card {
    bottom: var(--safe-b);
  }

  .setup-tabs {
    flex-direction: row;
  }

  .tab-btn {
    min-height: 48px;
  }

  .calendar-item {
    display: grid;
    gap: 0.2rem;
    padding: 1rem 1.1rem;
  }

  .badge,
  .badge-row a.badge {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Discord-Widget hat feste width=350 im Markup */
.discord-panel iframe {
  max-width: 100%;
}

/* --- 10. Flightsim: Globus & Guide -------------------------------------- */

@media (max-width: 1200px) {
  .globe-container {
    height: 380px;
    touch-action: pan-y;
  }

  .globe-hint {
    display: block;
    margin-top: 0.6rem;
    color: var(--muted);
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
  }
}

@media (max-width: 640px) {
  .globe-container {
    height: 300px;
  }

  .globe-legend {
    gap: 0.75rem 1.25rem;
  }

  .atc-line {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    padding: 0.9rem 1rem;
  }

  .atc-line .role {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border: 1px solid currentColor;
    font-size: 0.75rem;
  }

  .atc-line p {
    font-size: 0.85rem;
    line-height: 1.55;
  }

  .flight-phase h3 {
    font-size: 1.5rem;
  }
}

/* --- 11. Galerie & Foto-Grid -------------------------------------------- */

@media (max-width: 640px) {
  .photo-grid {
    columns: 2 140px;
    column-gap: 4px;
  }

  .photo-card {
    margin-bottom: 4px;
  }

  .photo-card .download-link {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }

  .gallery-toolbar {
    display: grid;
    gap: 0.75rem;
  }

  .gallery-toolbar .btn {
    width: 100%;
  }

  .lightbox {
    padding: 0.75rem;
  }

  .lightbox-close {
    top: 0.75rem;
    right: 0.75rem;
    width: 44px;
    height: 44px;
  }

  .lightbox-nav {
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
  }

  .lightbox-prev {
    left: 0.5rem;
  }

  .lightbox-next {
    right: 0.5rem;
  }
}

@media (min-width: 641px) and (max-width: 1200px) {
  .photo-grid {
    columns: 3 200px;
  }
}

/* --- 12. Admin ---------------------------------------------------------- */

@media (max-width: 1200px) {
  .admin-shell {
    padding: 1.5rem 0 3rem;
  }

  .admin-header {
    align-items: flex-start;
  }

  .admin-image-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .login-box {
    margin: 3rem auto;
  }
}

@media (max-width: 640px) {
  .admin-header {
    display: grid;
    gap: 0.75rem;
  }

  .admin-header .btn {
    width: 100%;
  }

  .admin-image-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Hover-Overlay ist auf Touch nicht erreichbar → dauerhaft sichtbar */
  .admin-image-card .actions {
    opacity: 1;
    background: linear-gradient(to top, rgba(4, 7, 12, 0.85) 45%, transparent);
  }

  .admin-image-card .actions button {
    min-height: 36px;
  }

  .gallery-row {
    display: grid;
    gap: 0.3rem;
    min-height: 60px;
    align-content: center;
  }

  .upload-dropzone {
    padding: 1.5rem 1rem;
  }

  .upload-queue-item {
    flex-wrap: wrap;
  }
}

/* --- 13. Footer --------------------------------------------------------- */

@media (max-width: 640px) {
  footer {
    padding: 1.75rem 0 calc(2rem + var(--safe-b));
  }

  footer p {
    line-height: 2.2;
  }

  footer a {
    padding: 0.2rem 0;
  }
}
