/* Galerie im Instagram-Layout - gemeinsam fuer /insta/ und /insta-<thema>/ */
:root {
  --bg: #000;
  --bg2: #121212;
  --line: #262626;
  --text: #f5f5f5;
  --text2: #a8a8a8;
  --gold: #b8a262;
  --gold-l: #d4bc82;
  --heart: #ff3040;
  --f: 'Inter', system-ui, -apple-system, sans-serif;
  --f-head: 'Playfair Display', Georgia, serif;
  /* Farben je Website: insta/theme.css (optional) ueberschreibt nur diese Variablen. */
  --topbar-bg: var(--bg);
  --topbar-text: var(--text);
  --btn: #363636;
  --btn-h: #4a4a4a;
  --btn-text: var(--text);
  --primary-text: #000;
  --link: #e0f1ff;
  --overlay: rgba(0,0,0,.86);
  --nav-bg: rgba(255,255,255,.85);
  --nav-text: #000;
  --close: #fff;
  --toast-bg: #f5f5f5;
  --toast-text: #000;
  --f-name: var(--f);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--f); }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Topbar (nur mobil) ---- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--topbar-bg); color: var(--topbar-text); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 16px; }
.topbar-user { font-weight: 700; font-size: 16px; font-family: var(--f-name); }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; }
.icon-btn:hover { background: rgba(127,127,127,.18); }

.wrap { max-width: 1240px; margin: 0 auto; }

/* ---- Profil ---- */
.profile { display: grid; grid-template-columns: 86px 1fr; gap: 14px 20px; align-items: center; padding: 16px; }
.avatar-ring { align-self: start; padding: 3px; border-radius: 50%; background: linear-gradient(45deg, var(--gold-dark, #8a7244), var(--gold-l), var(--gold)); }
.avatar { width: 100%; height: auto; aspect-ratio: 1; border-radius: 50%; object-fit: cover; border: 3px solid var(--bg); }
.username { font-size: clamp(16px, 4.6vw, 20px); font-weight: 400; overflow-wrap: anywhere; }
.profile-row .profile-actions { display: none; }
.profile-actions { display: flex; gap: 8px; }
.profile-actions-m { padding: 0 16px 16px; }
.profile-actions-m .btn { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 16px; border-radius: 8px; background: var(--btn); color: var(--btn-text); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .2s; }
.btn:hover { background: var(--btn-h); color: var(--btn-text); }
.btn-primary { background: var(--gold); color: var(--primary-text); }
.btn-primary:hover { background: var(--gold-l); color: var(--primary-text); }

.stats { display: flex; gap: 22px; list-style: none; margin-top: 8px; }
.stats { justify-content: space-between; max-width: 260px; }
.stats li { display: flex; flex-direction: column; font-size: 14px; line-height: 1.3; color: var(--text); }
.stats strong { font-weight: 600; }

.bio { grid-column: 1 / -1; font-size: 14px; }
.bio-name { font-weight: 600; font-family: var(--f-name); }
.bio-cat { color: var(--text2); }
.bio-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 2px; }
.bio-links a { color: var(--link); font-weight: 600; }
.bio-links a:hover { text-decoration: underline; }

/* ---- Reiter ---- */
.tabs { display: flex; justify-content: center; border-top: 1px solid var(--line); }
.tab { display: flex; align-items: center; gap: 6px; height: 46px; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text2); }
.tab svg { width: 14px; height: 14px; }
.tab.is-active { color: var(--text); border-top: 1px solid var(--text); margin-top: -1px; }

/* ---- Raster: mobil 3, Desktop 5 Spalten ---- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.tile { position: relative; display: block; aspect-ratio: 3 / 4; overflow: hidden; background: var(--bg2); }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.tile-hover { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 6px; background: rgba(0,0,0,.35); color: #fff; font-weight: 700; font-size: 16px; opacity: 0; transition: opacity .2s; }
.tile-hover svg { width: 20px; height: 20px; fill: #fff; stroke: none; }
@media (hover: hover) {
  .tile:hover .tile-hover { opacity: 1; }
}

/* ---- Leere Galerie ---- */
.empty { padding: 48px 16px; text-align: center; color: var(--text2); }

/* ---- Footer ---- */
.foot { padding: 36px 16px 48px; text-align: center; color: var(--text2); font-size: 12px; }
.foot a:hover { color: var(--text); }

/* ---- Toast ---- */
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translate(-50%, 20px); padding: 10px 18px; border-radius: 8px; background: var(--toast-bg); color: var(--toast-text); font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---- Beitragsansicht ---- */
body.is-locked { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 50; display: none; background: var(--overlay); }
.modal.is-open { display: flex; align-items: center; justify-content: center; }
.modal-close { position: absolute; top: 10px; right: 10px; z-index: 3; color: var(--close); }
.modal-close svg { width: 28px; height: 28px; }
.modal-nav { position: absolute; top: 50%; z-index: 3; display: grid; place-items: center; width: 32px; height: 32px; margin-top: -16px; border-radius: 50%; background: var(--nav-bg); color: var(--nav-text); }
.modal-nav svg { width: 18px; height: 18px; stroke-width: 2.4; }
.modal-nav[hidden] { display: none; }
@media (max-width: 767px) { .modal-nav { display: none; } }
.modal-prev { left: 16px; }
.modal-next { right: 16px; }

.post { display: flex; flex-direction: column; width: 100%; height: 100%; background: var(--bg); overflow-y: auto; }
.post-head { display: flex; align-items: center; gap: 10px; padding: 12px 52px 12px 14px; border-bottom: 1px solid var(--line); }
.post-head img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.post-head strong { font-weight: 600; }
.post-head span { display: block; color: var(--text2); font-size: 12px; }
.post-media { position: relative; background: #000; user-select: none; -webkit-user-select: none; }
.post-media img { width: 100%; height: auto; }
.post-burst { position: absolute; left: 50%; top: 50%; width: 96px; height: 96px; margin: -48px 0 0 -48px; fill: #fff; stroke: none; opacity: 0; transform: scale(.3); pointer-events: none; filter: drop-shadow(0 4px 18px rgba(0,0,0,.4)); }
.post-burst.is-on { animation: burst .9s ease-out; }
@keyframes burst {
  0% { opacity: 0; transform: scale(.3); }
  15% { opacity: 1; transform: scale(1.15); }
  30% { transform: scale(.95); }
  45%, 75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
.post-side { display: flex; flex-direction: column; }
.post-caption { padding: 4px 14px 0; white-space: pre-line; }
.post-caption:empty { display: none; }
.post-caption strong { font-weight: 600; margin-right: 4px; }
.post-actions { display: flex; align-items: center; gap: 4px; padding: 6px 8px 0; }
.post-actions button { display: grid; place-items: center; width: 40px; height: 40px; }
.post-actions button:hover { color: var(--text2); }
.post-actions svg { width: 26px; height: 26px; }
.btn-like.is-liked svg { fill: var(--heart); stroke: var(--heart); }
.btn-like.pop svg { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }
.post-likes { padding: 2px 14px 0; font-weight: 600; }
.post-date { padding: 4px 14px 16px; color: var(--text2); font-size: 11px; letter-spacing: .3px; text-transform: uppercase; }
.post-cta { margin: 0 14px 18px; }
.post-cta .btn { width: 100%; }

/* ---- Desktop ---- */
@media (min-width: 768px) {
  .topbar { display: none; }
  .wrap { padding: 0 20px; }
  .profile { grid-template-columns: 290px 1fr; grid-template-rows: auto 1fr; gap: 18px 28px; align-items: start; padding: 36px 0 44px; }
  .avatar-ring { width: 160px; justify-self: center; }
  .profile-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; }
  .profile-row .profile-actions { display: flex; }
  .profile-actions-m { display: none; }
  .avatar-ring { grid-row: 1 / 3; }
  .bio { grid-column: 2; }
  .stats { gap: 40px; margin-top: 20px; font-size: 16px; }
  .stats { justify-content: flex-start; max-width: none; }
  .stats li { display: block; font-size: 16px; }
  .grid { grid-template-columns: repeat(5, 1fr); gap: 4px; }

  .modal-prev { left: 20px; }
  .modal-next { right: 20px; }
  .modal-close { top: 14px; right: 18px; }
  .post { display: grid; grid-template-columns: auto 360px; grid-template-rows: auto 1fr; width: auto; height: auto; max-width: calc(100vw - 140px); max-height: calc(100vh - 60px); overflow: hidden; border-radius: 4px; }
  .post-head { grid-column: 2; grid-row: 1; padding-right: 14px; }
  .post-media { grid-column: 1; grid-row: 1 / 3; display: flex; align-items: center; }
  .post-media img { width: auto; height: calc(100vh - 60px); max-height: 1100px; max-width: calc(100vw - 500px); object-fit: contain; }
  .post-side { grid-column: 2; grid-row: 2; overflow-y: auto; }
  .post-caption { padding-top: 14px; flex: 1; }
  .post-caption:empty { display: block; flex: 1; }
  .post-actions { border-top: 1px solid var(--line); margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
