/* ==========================================================================
   Design-Tokens
   ========================================================================== */
:root {
  --bg: #ffffff;
  --ink: #161614;
  --ink-soft: #55534c;
  --accent: #2f5d50;
  --line: #dad7ce;
  --accent-color-a: #44cc00;

  --font-mono: "IBM Plex Mono", monospace;
  --font-serif: "IBM Plex Mono", monospace;

  --header-h: 52px;

  /* Maximalbreite des Modals: entspricht der Kachelbreite im
     einspaltigen Layout (700px-Breakpoint minus Grid-Padding von
     2×30px). Bei Bedarf zusammen mit dem 700px-Breakpoint weiter
     unten anpassen. */
  --modal-max-width: 640px;
  /* Mindestabstand des Modals zum Fensterrand (Öffnen + Ziehen) */
  --modal-margin: 24px;
}

/* ==========================================================================
   Milligram-Überschreibungen
   ========================================================================== */
html {
  font-size: 62.5%; /* Milligram-Konvention: 1rem = 10px */
}

body {
  font-family: var(--font-mono);
  background-color: #f2f2f2; /* Kachel-Zwischenraum transparent */
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

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

button {
  font-family: inherit;
}

/* Text-Link-Optik für Info / neu mischen / × — kein Button-Look,
   keine Hintergrund-Einfärbung in irgendeinem Zustand (überschreibt
   Milligrams globale button:hover/:focus-Regel gezielt) */
.btn-plain,
.prose-info a {
  display: inline;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-mono);
  font-size: 3.2rem;
  font-weight: 400;
  line-height: normal;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.btn-plain:hover,
.btn-plain:focus,
.btn-plain:focus-visible,
.prose-info a:hover,
.prose-info a:focus,
.prose-info a:focus-visible {
  background: transparent;
  border-color: transparent;
  outline: 0;
  color: var(--accent);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Header / Footer
   ========================================================================== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 16px;
}

.site-title {
  font-family: var(--font-mono);
  font-size: 3.2rem;
  font-weight: 600;
  color: var(--ink);
}

.site-main {
  padding-top: var(--header-h);
}

.site-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  color: var(--ink-soft);
  text-align: center;
}

.empty-state {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--ink-soft);
  text-align: center;
  padding: 96px 24px;
}

@media (min-width: 600px) {
  :root {
    --header-h: 60px;
  }
}

/* ==========================================================================
   Bild-Grid + Kacheln 
   ========================================================================== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  align-items: start; /* verhindert Streckung unterschiedlich hoher Kacheln */
  gap: 10px; /* Abstand zwischen Kacheln */
  padding: 50px;
}

@media (min-width: 480px) {
  .tile-grid { grid-template-columns: repeat(1, 1fr); }
}
@media (min-width: 700px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .tile-grid { grid-template-columns: repeat(4, 1fr); }
}

.tile {
  position: relative;
  display: block;
  height: auto;
  /*overflow: hidden;*/
  background: transparent;
  cursor: grab;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0;
  line-height: normal;
  font-weight: normal;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  white-space: normal;
  /* Verschieben per Maus/Finger: kein Text-/Bild-Markieren, kein
     browsereigenes Scroll-Gesture-Handling auf der Kachel selbst
     (Scrollen bleibt außerhalb der Kacheln normal möglich) */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.tile.is-dragging {
  cursor: grabbing;
}

.tile-media {
  display: block;
}

/* Bild-Schatten: rechteckig für normale Fotos (jpg/webp), entlang
   der Silhouette für freigestellte PNGs. Kein Blur — passt zum
   hart-kantigen, reduzierten Look. Nur bei Bildern in voller Größe
   (siehe app.js), verkleinerte Bilder bleiben ohne Schatten. */
.tile-media img.shadow-box {
  box-shadow: 6px 6px 6px rgba(22, 22, 20, 0.35);
}

.tile-media img.shadow-drop {
  filter: drop-shadow(6px 6px 5px rgba(22, 22, 20, 0.35));
}

.tile img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none; /* Drag-Erkennung läuft über die Kachel (button), nicht das Bild */
  -webkit-user-drag: none;
}

/* Leere Platzhalter-Kachel: nimmt ihren Platz im Grid ein, ist aber
   nicht klickbar/ziehbar. aspect-ratio sorgt für eine Höhe, die etwa
   der eines typischen Fotos entspricht. */
.tile-empty {
  aspect-ratio: 4 / 3;
  /* border: 1px dashed var(--line); */
  cursor: default;
  touch-action: auto;
}

/* Titel-Label: weißes Kästchen mit schwarzem Rand, mittig auf dem
   Bild, Zeilenumbruch statt Kürzung */
.tile .tile-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translateY(4px);
  max-width: calc(100% - 32px);
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: normal;
  color: var(--ink);
  text-align: center;
   white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

/* Kein Hintergrund-Einfärben der Kachel beim Hover/Fokus (überschreibt
   Milligrams globale button:hover/:focus-Regel), Label wird sichtbar */
.tile:hover,
.tile:focus,
.tile:focus-visible {
  z-index: 5;
  background-color: transparent;
  border-color: transparent;
  color: inherit;
  outline: 0;
}

.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tile:hover .tile-label,
.tile:focus-visible .tile-label {
  opacity: 1;
  transform: translate(-50%, -50%) translateY(0);
}

/* Während des Ziehens kein Label einblenden (würde beim schnellen
   Verschieben nur flackern) */
.tile.is-dragging .tile-label {
  opacity: 0;
}

/* ==========================================================================
   Modal / Infofenster
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: transparent; /* kein Abdunkeln beim Öffnen */
}

.modal-backdrop.is-open {
  display: block;
}

.modal-panel {
  position: fixed;
  /* left/top/transform werden beim Öffnen bzw. Ziehen per JS gesetzt */
  width: 100%;
  max-width: min(var(--modal-max-width), calc(100vw - 2 * var(--modal-margin)));
  max-height: calc(100vh - 2 * var(--modal-margin));
  margin: 0;
  overflow-y: auto;
  background: #fff69b; /* var(--bg); */
  border: none; /* 1px solid var(--ink);*/ 
  box-shadow: 6px 6px 6px rgba(22, 22, 20, 0.35);
  opacity: 0;
  transition: left 0.25s ease, top 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
}

/* Während des Ziehens keine Transition (würde der Maus/dem Finger hinterherhinken) */
.modal-panel.is-dragging {
  transition: none;
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  /*background: var(--bg); */
  cursor: grab;
  touch-action: none; /* Ziehen der Titelzeile soll nicht die Seite scrollen */
  -webkit-user-select: none;
  user-select: none;
}

.modal-panel.is-dragging .modal-head {
  cursor: grabbing;
}

.modal-title {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  margin: 4px 0 0;
  letter-spacing: normal;
}

.modal-close {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
  border: 0;
  background: transparent;
  width: auto;
  height: auto;
  padding: 0;
  cursor: pointer; /* eigener Cursor, unabhängig vom "grab" der Titelzeile */
}

@media (prefers-reduced-motion: reduce) {
  .modal-panel {
    transition: none !important;
  }
}

/* Markdown-Inhalt im Infofenster */
.prose-info {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--ink);
  padding: 12px;
}

.prose-info h1 {
  display: none; /* Titel wird bereits oben im Modal-Header angezeigt */
  letter-spacing: normal;
}

.prose-info h2,
.prose-info h3 {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: normal;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.prose-info p { 
	margin: 0 0 1em;
}
/*
.prose-info a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
*/
.prose-info ul,
.prose-info ol {
  margin: 0 0 1em 1.2em;
}

.prose-info li {
  margin-bottom: 0.3em;
}

.prose-info strong {
  font-weight: 600;
}

.prose-info em,
.prose-info i {
  font-style: italic;
}

.prose-info hr {
  border: none;
  border-top: 1px solid var(--ink);
  margin: 1.5em 0;
}

.prose-info a {
  font-size: 1.6rem;
}

/* Reserve für kleinere Anwendungsfälle */
.text-sm {
  font-size: 1.6rem;
}

@media (prefers-reduced-motion: reduce) {
  .tile-label {
    transition: none !important;
  }
}
