/* ==========================================================================
   Noahs Werkstatt – Stylesheet
   Blaupausen-Look: tiefes Blau, weiße Konstruktionslinien, Papier-Karten.
   Farben angelehnt an die alte Version der Seite (#215f9c & Co).
   Mobile-first.
   ========================================================================== */

/* ---------- Lokale Schriften ---------- */
@font-face {
  font-family: "Fugaz One";
  src: url("../fonts/FugazOne-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

/* ---------- Farbpalette & Grundwerte ---------- */
:root {
  --bg: #215f9c;            /* das Blau der alten Seite */
  --bg-deep: #173f6b;       /* dunkleres Blau für Verlauf & Nav */
  --bg-panel: rgba(255, 255, 255, 0.08);  /* transparente Panels */
  --panel-line: rgba(255, 255, 255, 0.22);
  --paper: #fdfefe;         /* Karten = weißes Papier */
  --ink: #1c3a5a;           /* Text auf Papier */
  --ink-soft: #4c6784;      /* abgeschwächter Text auf Papier */
  --text-light: #eaf3fc;    /* Text auf Blau */
  --text-dim: #b8d2ea;      /* gedämpfter Text auf Blau */
  --accent: #22abf3;        /* helles Akzent-Blau (alte Hover-Farbe) */
  --accent-soft: #7fc8f5;
  --stamp: #ff7a59;         /* Prüfstempel-Rot – nur für Stempel & kleine Marken */
  --line-draw: #bfe0fa;     /* Bemaßungslinien */
  --blueprint: #1d4e82;     /* Blaupausen-Fenster in den Karten */
  --shadow: 0 4px 14px rgba(4, 20, 40, 0.3);
  --shadow-lift: 0 16px 34px rgba(4, 20, 40, 0.4);

  --font-display: "Fugaz One", "Rubik", sans-serif;
  --font-body: "Rubik", system-ui, sans-serif;
}

/* ---------- Reset & Basis ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Safari/iOS: kein grauer Tipp-Flash beim Antippen von Buttons/Links */
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem; /* Sticky-Nav nicht über Ankerziele legen */
  -webkit-text-size-adjust: 100%; /* iOS vergrößert sonst Text bei Drehung ins Querformat */
}

body {
  font-family: var(--font-body);
  color: var(--text-light);
  background: linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 30%, var(--bg) 80%, var(--bg-deep) 100%);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Interaktive Elemente: kein Doppel-Tap-Zoom-Delay auf Touch-Geräten (iPhone/iPad) */
button,
a,
.card-upload-btn,
.crop-h {
  touch-action: manipulation;
}


/* Blaupausen-Raster über der ganzen Seite: feines Gitter + gröbere Linien */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
}

/* Inhalt über dem Raster halten */
.nav,
.hero,
.section,
.footer {
  position: relative;
  z-index: 1;
}

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

a {
  color: var(--accent-soft);
}

/* Display-Schrift (Fugaz One – wie auf der alten Seite) */
.display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

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

/* ---------- Navigation ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.2rem;
  background: rgba(19, 47, 78, 0.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--panel-line);
}

.nav-logo {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 3.5vw, 1.3rem);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: clamp(0.6rem, 2.5vw, 1.2rem);
}

.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

/* Hover-Farbe siehe @media (hover: hover) am Dateiende */

/* ---------- Hero: das Zeichnungsblatt ---------- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  text-align: center;
  max-width: 1060px;
  margin: clamp(1rem, 3vw, 2rem) auto 0;
  padding: clamp(3.5rem, 8vw, 6rem) clamp(1.5rem, 5vw, 4rem) clamp(6rem, 10vw, 7.5rem);
  min-height: min(78vh, 720px);
}

/* DIN-Zeichnungsrahmen: doppelte Linie + Eckmarken */
.sheet {
  position: absolute;
  inset: 0.9rem;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  outline: 1px solid rgba(255, 255, 255, 0.14);
  outline-offset: 5px;
}

.sheet-mark {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 0 solid var(--accent-soft);
}

.sheet-mark-tl { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.sheet-mark-tr { top: -1px; right: -1px; border-top-width: 2px; border-right-width: 2px; }
.sheet-mark-bl { bottom: -1px; left: -1px; border-bottom-width: 2px; border-left-width: 2px; }
.sheet-mark-br { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }

.hero-kicker {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.9rem;
}

.hero-text h1 {
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  color: #fff;
  text-shadow: 0 3px 12px rgba(4, 20, 40, 0.35);
  text-wrap: balance;
}

.hero-sub {
  max-width: 34rem;
  margin: 1.1rem auto 0;
  font-size: 1.08rem;
  color: var(--text-dim);
}

/* ---------- Bemaßungslinien (Hero & Überschriften) ---------- */
.dim {
  color: var(--line-draw);
  overflow: visible;
}

.hero-dim {
  width: min(340px, 80%);
  margin: 0.9rem auto 0;
}

.dim-label {
  fill: var(--line-draw);
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.05em;
}

/* Linien "zeichnen" sich, sobald sichtbar (Hero: beim Laden) */
.dim-line,
.dim-ext {
  stroke-dasharray: 140;
  stroke-dashoffset: 140;
}

.dim-arrow,
.dim .dim-label {
  opacity: 0;
}

.hero-dim .dim-line,
.hero-dim .dim-ext,
.reveal.in-view .dim-line,
.reveal.in-view .dim-ext {
  animation: dim-draw 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hero-dim .dim-line,
.hero-dim .dim-ext {
  animation-delay: 0.45s;
}

.hero-dim .dim-arrow,
.hero-dim .dim-label,
.reveal.in-view .dim-arrow,
.reveal.in-view .dim-label {
  animation: dim-fade 0.4s ease-out 0.55s forwards;
}

.hero-dim .dim-arrow,
.hero-dim .dim-label {
  animation-delay: 1s;
}

@keyframes dim-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes dim-fade {
  to { opacity: 1; }
}

/* Schriftfeld unten rechts im Zeichnungsrahmen */
.title-block {
  position: absolute;
  right: 0.9rem;
  bottom: 0.9rem;
  min-width: 215px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-light);
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-right: 0;
  border-bottom: 0;
  background: rgba(10, 30, 54, 0.45);
  backdrop-filter: blur(2px);
}

.tb-row {
  display: flex;
  gap: 0.8rem;
  padding: 0.28rem 0.6rem;
}

.tb-row + .tb-row {
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.tb-split {
  justify-content: space-between;
}

.tb-split > span {
  display: flex;
  gap: 0.45rem;
}

.tb-label {
  color: var(--text-dim);
  margin-right: 0.45rem;
  font-weight: 500;
}

.tb-split .tb-label {
  margin-right: 0;
}

/* Hero-Entrance: Kicker, Titel, Untertitel, Buttons nacheinander */
.hero-text > * {
  animation: hero-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.hero-text > *:nth-child(2) { animation-delay: 0.08s; }
.hero-text > *:nth-child(3) { animation-delay: 0.16s; }
.hero-text > *:nth-child(4) { animation-delay: 0.24s; }
.hero-text > *:nth-child(5) { animation-delay: 0.32s; }

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

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

/* Blaupausen-Explosionszeichnung: weich in den Hintergrund geblendet,
   schwebt langsam wie ein Bauteil in der Montage-Animation */
.hero-art {
  position: relative;
}

.hero-blueprint {
  width: clamp(280px, 38vw, 460px);
  height: auto;
  -webkit-mask-image: radial-gradient(ellipse 72% 70% at 50% 48%, #000 48%, transparent 74%);
  mask-image: radial-gradient(ellipse 72% 70% at 50% 48%, #000 48%, transparent 74%);
  animation: blueprint-float 9s ease-in-out infinite;
  will-change: transform;
}

@keyframes blueprint-float {
  0%, 100% { transform: translateY(0) rotate(0.4deg); }
  50% { transform: translateY(-12px) rotate(-0.6deg); }
}

@keyframes gear-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- CAD-Fadenkreuz im Hero (nur echte Mauszeiger) ---------- */
.crosshair-x,
.crosshair-y {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease-out;
  z-index: 2;
}

.crosshair-x {
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.35);
}

.crosshair-y {
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px dashed rgba(255, 255, 255, 0.35);
}

.crosshair-label {
  position: absolute;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--line-draw);
  background: rgba(10, 30, 54, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease-out;
  z-index: 2;
  white-space: nowrap;
}

.hero.crosshair-on .crosshair-x,
.hero.crosshair-on .crosshair-y,
.hero.crosshair-on .crosshair-label {
  opacity: 1;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #072c4d;
  box-shadow: var(--shadow);
}

.btn-ghost {
  border: 2px solid var(--panel-line);
  color: var(--text-light);
}

.btn-big {
  font-size: 1.05rem;
  padding: 0.85rem 1.8rem;
}

/* ---------- Sektionen (allgemein) ---------- */
.section {
  max-width: 1000px;
  margin: 0 auto;
  padding: 4.5rem 1.5rem;
}

.section h2 {
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  color: #fff;
  margin-bottom: 2rem;
}

/* Bemaßungslinie unter Überschriften */
.h-dim {
  width: 130px;
  margin-top: 0.4rem;
}

.section-intro {
  margin: -1rem 0 2rem;
  color: var(--text-dim);
}

/* ---------- Über mich ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: start;
}

.about-text p + p {
  margin-top: 1rem;
}

.about-text {
  color: var(--text-dim);
}

.about-text strong {
  color: #fff;
}

.about-note {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--accent-soft);
  margin-top: 1.2rem;
}

.about-art {
  color: var(--accent-soft);
  justify-self: center;
}

.about-art .sketch {
  width: 110px;
  transform: rotate(3deg);
}

/* Die Flügel der kleinen Windmühle drehen sich – wie früher.
   Wichtig: view-box als Bezugssystem, damit der Drehpunkt exakt
   auf der Nabe (55|54 in viewBox-Koordinaten) liegt. */
.mill-blades {
  transform-box: view-box;
  transform-origin: 55px 54px;
  animation: gear-spin 12s linear infinite;
}

/* --- Werkzeugwand --- */
.tools-heading {
  font-size: 1.35rem;
  color: #fff;
  margin: 3.5rem 0 1.2rem;
}

.tool-wall {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 1.1rem;
  padding: 1.6rem;
  background: var(--bg-panel);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
}

/* Jedes Werkzeug hängt leicht schräg an einem "Nagel" */
.tool {
  --tilt: 0deg;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.2rem 0.8rem 1rem;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
}

/* Der Nagel */
.tool::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg-deep);
  transform: translateX(-50%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.35);
}

.tool-icon {
  width: 38px;
  height: 38px;
  color: var(--bg);
}

/* ---------- Projekte ---------- */
.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.2rem;
}

/* Karten wie hingelegte Zeichenblätter – mit feiner Papierkörnung */
.project-card {
  --tilt: 0deg;
  position: relative;
  display: block;
  padding: 1.4rem;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.23 0 0 0 0 0.35 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23p)'/%3E%3C/svg%3E");
  color: var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  text-decoration: none;
  transform: rotate(var(--tilt));
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Klebestreifen oben */
.project-card::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 50%;
  width: 92px;
  height: 26px;
  background: rgba(210, 228, 245, 0.55);
  transform: translateX(-50%) rotate(-3deg);
  border-radius: 2px;
}

/* "Aufnehmen"-Effekt beim Hover siehe @media (hover: hover) am Dateiende */

/* Blaupausen-Fenster: dunkles Blau mit feinem Raster & weißen Linien */
.card-media {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 160px;
  margin-bottom: 1.1rem;
  border-radius: 8px;
  background-color: var(--blueprint);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 16px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.blueprint-sketch {
  width: 150px;
}

.placeholder-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
}

.project-card h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.project-card p {
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1rem;
}

.card-tags span {
  padding: 0.15rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #135a94;
  background: rgba(34, 171, 243, 0.12);
  border: 1px solid rgba(34, 171, 243, 0.45);
  border-radius: 999px;
}

/* ---------- Projekt-Upload & Galerie ---------- */
.project-card[data-project] {
  cursor: pointer;
}

.card-media {
  position: relative;
  overflow: hidden;
}

/* Wrapper für die Buttons oben rechts im Kartenbild – Flexbox statt
   einzeln geschätzter Absolut-Positionen, damit sich "Hochladen" und der
   Link-Button nie überlappen, egal wie breit der Text gerendert wird. */
.card-media-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card-upload-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--text-light);
  background: rgba(4, 20, 40, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.card-upload-btn svg {
  width: 14px;
  height: 14px;
}

/* Kleiner Link-Button neben "Hochladen": holt ein per Cloudinary-Link
   hochgeladenes Foto (z.B. vom iPhone) in den echten Projektordner */
.card-hint {
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
  opacity: 0.75;
}

.upload-badge {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  padding: 0.15rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
  background: rgba(4, 20, 40, 0.6);
  border-radius: 999px;
}

/* Galerie-Modal */
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(4, 14, 28, 0.75);
  backdrop-filter: blur(3px);
}

.gallery-modal[hidden] {
  display: none;
}

.gallery-panel {
  width: min(880px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 1.4rem;
  box-shadow: var(--shadow-lift);
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
}

.gallery-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.2rem;
}

.gallery-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(28, 58, 90, 0.08);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.gallery-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gallery-select-toggle,
.gallery-delete-selected {
  flex-shrink: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-body);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.gallery-select-toggle {
  color: var(--ink);
  background: rgba(28, 58, 90, 0.06);
  border: 1px solid rgba(28, 58, 90, 0.2);
}

.gallery-delete-selected {
  color: #fff;
  background: #c0392b;
  border: 1px solid #c0392b;
}

.gallery-empty {
  font-size: 0.9rem;
  color: var(--ink-soft);
}

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

/* Bei nur einem Element nicht auf halbe Breite quetschen */
.gallery-grid:has(.gallery-item:only-child) {
  grid-template-columns: minmax(0, 1fr);
}

.gallery-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  overflow: hidden;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s, outline-color 0.15s;
}

/* Auswahl-Kreis oben links auf jeder Kachel – nur sichtbar im Auswahl-Modus */
.gallery-item-check {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 3;
  width: 22px;
  height: 22px;
  display: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid var(--accent);
}

.gallery-grid.selecting .gallery-item {
  cursor: pointer;
}

.gallery-grid.selecting .gallery-item-check {
  display: block;
}

.gallery-item.selected {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.gallery-item.selected .gallery-item-check {
  background: var(--accent);
}

.gallery-item.selected .gallery-item-check::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid #072c4d;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.gallery-item-image img {
  width: 100%;
  height: 240px;
  border: 1px solid rgba(28, 58, 90, 0.15);
  border-radius: 10px;
  object-fit: cover;
}

.gallery-item-file {
  padding: 0.8rem 0.5rem;
  background: rgba(34, 171, 243, 0.08);
  border: 1px solid rgba(34, 171, 243, 0.3);
  text-align: center;
}

.gallery-item-file svg {
  color: var(--accent);
}

.gallery-file-name {
  font-size: 0.72rem;
  font-weight: 600;
  word-break: break-word;
}

.gallery-file-size {
  font-size: 0.68rem;
  color: var(--ink-soft);
}

/* STL-Kachel: gleiche Optik wie eine Datei-Kachel, aber als Button (öffnet 3D-Vorschau) */
.gallery-item-stl {
  padding: 0.8rem 0.5rem;
  background: rgba(34, 171, 243, 0.08);
  border: 1px solid rgba(34, 171, 243, 0.3);
  text-align: center;
  font-family: inherit;
  cursor: pointer;
}

.gallery-item-stl svg {
  color: var(--accent);
}

.gallery-file-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* 3D-Vorschau-Modal */
.stl-panel {
  width: min(640px, 100%);
}

.stl-viewer-canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  margin-bottom: 1.1rem;
  overflow: hidden;
  border-radius: 8px;
  background-color: var(--blueprint);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 16px 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#stl-viewer-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#stl-viewer-canvas:active {
  cursor: grabbing;
}

.stl-viewer-hint {
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

.stl-viewer-download {
  display: block;
  text-align: center;
}

/* PDF-Kachel: echtes Mini-Vorschaubild statt nur Icon */
.gallery-item-pdf {
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(34, 171, 243, 0.3);
  border-radius: 10px;
  cursor: pointer;
}

/* Die erste PDF-Seite wird per PDF.js als sauberes Bild gerendert –
   dadurch kein dunkler Rand ("schwarzer Balken") wie beim eingebetteten
   PDF-Viewer. */
.gallery-pdf-thumb-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 240px;
  overflow: hidden;
  background: #fff;
  border-bottom: 1px solid rgba(28, 58, 90, 0.15);
}

.gallery-pdf-thumb-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.gallery-pdf-thumb-wrap.pdf-thumb-fallback {
  flex-direction: column;
  gap: 0.3rem;
  color: var(--accent);
}

.pdf-thumb-fallback-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.gallery-item-pdf .gallery-file-name {
  display: block;
  padding: 0.5rem;
}

/* PDF-Vorschau-Modal */
.pdf-panel {
  width: min(760px, 100%);
}

.pdf-viewer-frame-wrap {
  margin-bottom: 1.1rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#pdf-viewer-frame {
  display: block;
  width: 100%;
  height: 65vh;
  border: 0;
  background: #fff;
}

/* ---------- Bild-Editor (Zuschneiden & Drehen) ---------- */
.editor-panel {
  width: min(640px, 100%);
  text-align: center;
}

.editor-filename {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-soft);
  word-break: break-word;
}

.editor-stage {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
  background: var(--blueprint);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 16px 16px;
  border-radius: 8px;
}

.editor-canvas-wrap {
  position: relative;
  touch-action: none;
  line-height: 0;
}

#editor-canvas {
  display: block;
  user-select: none;
}

/* Zuschnitt-Rahmen mit abgedunkeltem Außenbereich */
.editor-crop {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 9999px rgba(4, 14, 28, 0.55);
  cursor: move;
  touch-action: none;
}

/* Drittel-Raster als Orientierung */
.editor-crop::before,
.editor-crop::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.editor-crop::before {
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  border-right: 1px solid rgba(255, 255, 255, 0.35);
  left: 33.33%;
  right: 33.33%;
}
.editor-crop::after {
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  top: 33.33%;
  bottom: 33.33%;
}

.crop-h {
  position: absolute;
  width: 16px;
  height: 16px;
  background: #fff;
  border: 1px solid var(--accent);
  border-radius: 50%;
  touch-action: none;
}

.crop-nw { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-ne { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-se { bottom: -8px; right: -8px; cursor: nwse-resize; }
.crop-sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-n { top: -8px; left: 50%; margin-left: -8px; cursor: ns-resize; }
.crop-s { bottom: -8px; left: 50%; margin-left: -8px; cursor: ns-resize; }
.crop-w { left: -8px; top: 50%; margin-top: -8px; cursor: ew-resize; }
.crop-e { right: -8px; top: 50%; margin-top: -8px; cursor: ew-resize; }

.editor-hint {
  margin: 0.7rem 0 0.4rem;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.editor-tool-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--ink);
  background: rgba(34, 171, 243, 0.1);
  border: 1px solid rgba(34, 171, 243, 0.4);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
}

.editor-actions .btn-ghost {
  color: var(--ink);
  border-color: rgba(28, 58, 90, 0.3);
}

/* Login-Modal (nur zum Löschen falscher Uploads) */
.login-panel {
  width: min(360px, 100%);
}

.login-hint {
  margin-bottom: 1rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.login-field {
  display: block;
  margin-bottom: 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.login-field input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  font-family: var(--font-body);
  color: var(--ink);
  background: rgba(28, 58, 90, 0.05);
  border: 1px solid rgba(28, 58, 90, 0.25);
  border-radius: 8px;
}

.login-submit {
  width: 100%;
  margin-top: 0.4rem;
}

.pdf-viewer-download {
  display: block;
  text-align: center;
}

/* ---------- Kontakt ---------- */
.section-contact {
  text-align: center;
}

.section-contact .h-dim {
  margin-inline: auto;
}

/* Prüfstempel – leicht verdreht, wie von Hand gestempelt */
.stamp {
  padding: 0.45rem 1.2rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--stamp);
  border: 2px solid var(--stamp);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(255, 122, 89, 0.25);
  transform: rotate(-4deg);
  opacity: 0.9;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' /%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0.25'/%3E%3C/filter%3E%3Crect width='120' height='40' fill='white' filter='url(%23n)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='40'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' /%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0.25'/%3E%3C/filter%3E%3Crect width='120' height='40' fill='white' filter='url(%23n)'/%3E%3C/svg%3E");
}

.contact-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  padding: 2.5rem 1.5rem;
  background: var(--bg-panel);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
}

.contact-line {
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  color: #fff;
}

.socials {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.4rem;
  margin-top: 0.4rem;
}

.socials a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  transition: color 0.2s, transform 0.2s;
}

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

/* ---------- Footer ---------- */
.footer {
  padding: 2rem 1.5rem 2.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  border-top: 1px solid var(--panel-line);
}

/* ---------- Scroll-Reveal-Animationen ---------- */
.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

/* Karten behalten dabei ihre Schräglage */
.project-card.reveal {
  transform: rotate(var(--tilt)) translateY(26px);
}

.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

.project-card.reveal.in-view {
  transform: rotate(var(--tilt)) translateY(0);
}

/* Reduzierte Bewegung respektieren */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal,
  .project-card.reveal {
    opacity: 1;
    transform: rotate(var(--tilt, 0deg));
    transition: none;
  }

  .hero-blueprint,
  .mill-blades,
  .hero-text > *,
  .dim-line,
  .dim-ext,
  .dim-arrow,
  .dim .dim-label {
    animation: none;
  }

  /* Bemaßungen ohne Animation sofort vollständig zeigen */
  .dim-line,
  .dim-ext {
    stroke-dashoffset: 0;
  }

  .dim-arrow,
  .dim .dim-label {
    opacity: 1;
  }
}

/* ---------- Größere Bildschirme ---------- */
@media (min-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .hero {
    flex-direction: row;
    text-align: left;
    justify-content: space-between;
    padding-top: 5.5rem;
  }

  .hero-sub {
    margin-inline: 0;
  }

  .hero-dim {
    margin-inline: 0;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .about-grid {
    grid-template-columns: 1fr 160px;
  }

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

/* ---------- Hover-Effekte nur für echte Maus-Zeiger (Desktop/Mac) ----------
   Auf iPhone/iPad (touch, kein echter Hover) bleiben Hover-Zustände nach
   dem Antippen sonst "hängen" – der erste Tap würde nur den Hover-Stil
   auslösen statt sofort zu klicken. Alle :hover-Regeln der Seite sind
   deshalb hier gebündelt und nur für Geräte mit Maus aktiv. */
@media (hover: hover) and (pointer: fine) {
  .nav-links a:hover {
    color: #fff;
    border-color: var(--accent);
  }

  .btn-primary:hover {
    background: #4fc0ff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lift);
  }

  .btn-ghost:hover {
    border-color: var(--accent);
    color: #fff;
    transform: translateY(-2px);
  }

  .tool:hover {
    transform: rotate(0deg) translateY(-4px);
    box-shadow: var(--shadow-lift);
  }

  .project-card:hover {
    transform: rotate(0deg) translateY(-8px);
    box-shadow: var(--shadow-lift);
  }

  .card-upload-btn:hover {
    background: var(--accent);
    color: #072c4d;
    transform: translateY(-1px);
  }

  .gallery-close:hover {
    background: rgba(28, 58, 90, 0.18);
  }

  .gallery-select-toggle:hover {
    border-color: var(--accent);
  }

  .gallery-delete-selected:hover {
    background: #a5301f;
  }

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

  .editor-tool-btn:hover {
    background: rgba(34, 171, 243, 0.22);
  }

  .editor-actions .btn-ghost:hover {
    border-color: var(--accent);
    color: var(--ink);
  }

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

/* ---------- iPhone/iPad: Safari-Präfixe, Safe-Area, Touch-Feintuning ---------- */

/* Safari braucht -webkit- für backdrop-filter (Galerie-/Modal-Hintergrund) */
.gallery-modal {
  -webkit-backdrop-filter: blur(3px);
}

/* Notch/Dynamic Island: feste Nav-Leiste nicht dahinter verstecken */
.nav {
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
}

/* Modal-Ränder an den Rand-Bereich (Notch/Home-Indikator) anpassen */
.gallery-modal {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

/* Beim Ziehen der Zuschnitt-Griffe/3D-Modell darf die Seite nicht mitscrollen */
.editor-crop,
.crop-h,
#stl-viewer-canvas {
  touch-action: none;
}

/* Kleine Bildschirme (iPhone SE bis iPhone Pro Max): Modal-Innenabstand
   verringern, damit mehr Platz für Inhalt bleibt */
@media (max-width: 480px) {
  /* Nav-Links dürfen auf schmalen Geräten nicht abgeschnitten werden */
  .nav {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .nav-links a {
    font-size: 0.85rem;
  }

  .gallery-modal {
    padding: 0.75rem;
  }

  .gallery-panel {
    padding: 1rem;
    border-radius: 14px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem;
  }

  .gallery-item-image img,
  .gallery-pdf-thumb-wrap {
    height: 160px;
  }

  #pdf-viewer-frame {
    height: 55vh;
  }

  .stl-viewer-canvas-wrap {
    aspect-ratio: 1 / 1;
  }

  .editor-stage {
    padding: 0.25rem 0;
  }

  .editor-tools,
  .editor-actions {
    gap: 0.4rem;
  }

  .editor-tool-btn,
  .editor-actions .btn {
    flex: 1 1 auto;
    text-align: center;
  }
}

/* Touch-Geräte (Finger statt Mauszeiger): Zuschnitt-Griffe größer machen,
   damit sie sich leicht mit dem Finger treffen lassen */
@media (pointer: coarse) {
  .crop-h {
    width: 26px;
    height: 26px;
  }

  .crop-nw { top: -13px; left: -13px; }
  .crop-ne { top: -13px; right: -13px; }
  .crop-se { bottom: -13px; right: -13px; }
  .crop-sw { bottom: -13px; left: -13px; }
  .crop-n { top: -13px; margin-left: -13px; }
  .crop-s { bottom: -13px; margin-left: -13px; }
  .crop-w { left: -13px; margin-top: -13px; }
  .crop-e { right: -13px; margin-top: -13px; }
}

/* iPad im Hoch- und Querformat: Galerie/Modale dürfen breiter werden */
@media (min-width: 768px) {
  .gallery-panel {
    padding: 1.8rem;
  }
}
