/* Mono – Sucher links, skeuomorpher Leder-Streifen rechts. Bewusst nur dunkel (Kamerawelt). */

/* Durchgehend IBM Plex: Sans für Beschriftungen, Mono für die Gravur am Filterrad */
@font-face {
  font-family: "IBM Plex Sans";
  src: url(assets/plex-sans.woff2) format("woff2");
  font-weight: 100 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url(assets/plex-mono-500.woff2) format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --ground: #0b0b0c;
  --leather: #17161a;
  --leather-hi: #24222a;
  /* Echte Ledertextur, als Ganzes eingepasst (hat eigenen Lichtverlauf, daher nicht gekachelt) */
  --leather-texture: url(assets/leather.webp) center / cover no-repeat;
  --chrome-hi: #f4f5f7;
  --chrome-mid: #b9bcc2;
  --chrome-lo: #5e6168;
  --chrome-deep: #2b2d31;
  --engrave: #e9e4d8;
  --engrave-dim: #9a958a;
  --danger: #d9a49a;
  /* gemeinsames Maß: Filterrad und Auslöser wachsen zusammen */
  --size: clamp(58px, min(11vw, 23dvh), 116px);
  --main: calc(var(--size) * 1.08);
  --share: calc(var(--size) * .58);
  --font-label: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--ground);
  color: var(--engrave);
  font-family: var(--font-label);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }


/* ---------- Gesamtlayout ---------- */
.camera {
  position: fixed; inset: 0;
  display: flex;
  height: 100dvh;
}

.viewfinder {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: env(safe-area-inset-left, 0px);
}
/* Das Foto füllt den ganzen Sucherbereich; das gespeicherte Bild hat genau dieses Seitenverhältnis */
.frame {
  position: relative;
  width: 100%; height: 100%;
  container-type: size;
  overflow: hidden;
  touch-action: none;
}
.frame canvas, .frame .still {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
.frame .still { object-fit: cover; }
#video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.flash {
  position: absolute; inset: 0;
  background: #fff; opacity: 0; pointer-events: none;
}
.flash.go { animation: flash 350ms ease-out; }
@keyframes flash { 0% { opacity: .95 } 100% { opacity: 0 } }


.frozen-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: clamp(8px, 3vw, 28px);
  padding: 28px 12px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
}

/* ---------- Leder-Streifen ---------- */
.strip {
  position: relative;
  flex: 0 0 calc(clamp(112px, 17vw, 180px) + env(safe-area-inset-right, 0px));
  padding: max(10px, 3dvh) env(safe-area-inset-right, 0px) max(10px, 3dvh) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background:
    radial-gradient(120% 60% at 30% 0%, rgba(255,255,255,.06), transparent 60%),
    var(--leather-texture),
    linear-gradient(90deg, var(--leather-hi), var(--leather) 30%, var(--leather));
  box-shadow: inset 6px 0 10px -4px rgba(0,0,0,.9), inset 0 0 40px rgba(0,0,0,.6);
}

/* ---------- Filterrad ---------- */
.dial-wrap {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding-bottom: 26px;          /* Platz für den Look-Namen in Grundhaltung */
  touch-action: none;
}
/* Skala um das Rad: in das Leder graviert, Buchstaben bleiben aufrecht */
.dial-scale {
  --ring: calc(var(--size) / 2);
  position: relative;
  width: calc(var(--size) + 40px); height: calc(var(--size) + 40px);
  display: grid; place-items: center;
  touch-action: none;
  cursor: grab;
}
.tick, .scale-letter {
  position: absolute; left: 50%; top: 50%;
  pointer-events: none;
}
.tick {
  width: 1.5px; height: 5px; margin: -2.5px 0 0 -.75px;
  border-radius: 1px;
  background: var(--engrave-dim);
  box-shadow: 0 -1px 0 rgba(0,0,0,.9);
  transform: rotate(var(--a)) translateY(calc(-1 * var(--ring) - 5px));
}
.tick.minor { height: 3px; margin-top: -1.5px; opacity: .45; transform: rotate(var(--a)) translateY(calc(-1 * var(--ring) - 4px)); }
.scale-letter {
  pointer-events: auto;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 500;
  color: var(--engrave-dim);
  text-shadow: 0 -1px 0 rgba(0,0,0,.9), 0 1px 0 rgba(255,255,255,.08);
  transform: rotate(var(--a)) translateY(calc(-1 * var(--ring) - 15px)) rotate(calc(var(--turn) - var(--a)));
  transition: color .2s, text-shadow .2s;
}
.scale-letter.on { color: var(--engrave); text-shadow: 0 -1px 0 rgba(0,0,0,.9), 0 0 6px rgba(233,228,216,.45); }
.dial {
  width: var(--size); height: var(--size);
  border-radius: 50%;
  position: relative;
  cursor: grab;
  touch-action: none;
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,.55), transparent 42%),
    repeating-conic-gradient(var(--chrome-hi) 0deg 2.2deg, var(--chrome-lo) 2.2deg 4.5deg),
    var(--chrome-mid);
  box-shadow:
    0 6px 10px rgba(0,0,0,.75),
    0 1px 0 rgba(255,255,255,.15),
    inset 0 0 0 1px rgba(0,0,0,.6),
    inset 0 -4px 8px rgba(0,0,0,.5);
  transition: transform .28s cubic-bezier(.3,1.4,.5,1);
}
.dial:active { cursor: grabbing; }
.dial:focus-visible { outline: 2px solid var(--engrave); outline-offset: 4px; }
.dial-cap {
  position: absolute; inset: 15%;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, rgba(255,255,255,.07) 0 1px, rgba(0,0,0,.05) 1px 2px),
    conic-gradient(from 200deg, #d9dce1, #8d9097, #eef0f3, #9b9ea5, #e3e5e9, #888b92, #d9dce1);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,.8),
    inset 0 -2px 3px rgba(0,0,0,.45),
    0 0 0 2px rgba(0,0,0,.35);
}
.dial-mark {
  position: absolute;
  left: 50%; top: 4%;
  width: 3px; height: 14%;
  margin-left: -1.5px;
  border-radius: 2px;
  background: #1a1a1a;
  box-shadow: 0 1px 0 rgba(255,255,255,.5);
}

.engraved, .look-name, .engraved-label, .brand, .g-title {
  text-shadow: 0 -1px 0 rgba(0,0,0,.9), 0 1px 0 rgba(255,255,255,.08);
}
.look-name {
  /* um den Radmittelpunkt gedreht, Abstand = Radius + Skala + etwas Luft */
  position: absolute;
  left: 50%; top: calc(var(--size) / 2 + 20px);
  transform: translate(-50%, -50%) rotate(var(--turn)) translateY(calc(var(--size) / 2 + 34px));
  white-space: nowrap;
  pointer-events: none;
  font-size: clamp(12px, min(1.6vw, 3.4dvh), 17px);
  font-weight: 500;
  letter-spacing: .32em;
  text-transform: uppercase;
  padding-left: .32em;
  line-height: 1.3;
}

/* ---------- Auslöser ----------
   Das Leder wölbt sich um den Knopf herum auf, in der Öffnung sitzt ein leicht konkaver,
   gebürsteter Chromknopf (großer Auslöser mit Gewindebuchse für den Drahtauslöser). */
.shutters { position: relative; display: flex; flex-direction: column; align-items: center; }
/* Großer Auslöser mittig unter dem Rad, Share-Auslöser leicht nach rechts versetzt darunter */
.shutters .btn-share {
  margin-top: calc(var(--share) * .2);
  transform: translateX(calc(var(--main) * .32));
}
.btn {
  -webkit-appearance: none; appearance: none;
  border: 0; padding: 0;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  display: grid; place-items: center;
  touch-action: manipulation;
  background: none;
  isolation: isolate;
}
/* Konkaver Anstieg des Leders zur Öffnung hin: nur Licht und Schatten über dem echten
   Streifen-Leder (keine eigene Scheibe → kein Rand, Textur läuft durch).
   Richtung per Kegelverlauf (Licht oben links), Profil per Maske: außen flach,
   zur Öffnung hin immer steiler → Schattierung nimmt nach innen stark zu. */
.btn::after {
  content: "";
  position: absolute; inset: -30%;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
  background:
    radial-gradient(circle closest-side, rgba(0,0,0,.45) 46%, transparent 54%),
    conic-gradient(from -45deg,
      rgba(255,255,255,.32) 0deg, rgba(255,255,255,.04) 80deg,
      rgba(0,0,0,.8) 180deg,
      rgba(255,255,255,.04) 280deg, rgba(255,255,255,.32) 360deg);
  -webkit-mask-image: radial-gradient(circle closest-side, #000 46%, rgba(0,0,0,.8) 56%, rgba(0,0,0,.45) 68%, rgba(0,0,0,.18) 82%, transparent 100%);
  mask-image: radial-gradient(circle closest-side, #000 46%, rgba(0,0,0,.8) 56%, rgba(0,0,0,.45) 68%, rgba(0,0,0,.18) 82%, transparent 100%);
}
/* Öffnung im Leder, aus der der Knopf kommt */
.btn::before {
  content: "";
  position: absolute; inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle, #050506 72%, #141317 100%);
  box-shadow:
    inset 0 3px 5px rgba(0,0,0,.95),
    0 0 0 1px rgba(0,0,0,.6),               /* Lederkante der Öffnung */
    0 1px 1px 1px rgba(255,255,255,.08);
}
.btn .cap {
  position: relative; z-index: 1;
  width: 68%; height: 68%;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    /* Mulde: Mitte etwas dunkler, Licht fällt auf den gegenüberliegenden Rand */
    radial-gradient(circle at 50% 50%, rgba(0,0,0,.16), transparent 62%),
    radial-gradient(circle at 66% 76%, rgba(255,255,255,.55), transparent 32%),
    /* gebürstete Oberfläche */
    repeating-radial-gradient(circle, rgba(255,255,255,.08) 0 1px, rgba(0,0,0,.06) 1px 2px),
    conic-gradient(from 210deg, #e4e6ea, #8f9299, #f1f2f4, #a0a3aa, #e7e9ec, #8a8d94, #e4e6ea);
  box-shadow:
    0 3px 5px rgba(0,0,0,.85),
    inset 0 2px 2px rgba(255,255,255,.85),
    inset 0 -2px 3px rgba(0,0,0,.45),
    0 0 0 1px rgba(0,0,0,.5);
  transition: transform .08s ease, box-shadow .08s ease, filter .08s ease;
}
/* Gewindebuchse für den Drahtauslöser */
.btn-main .cap::after {
  content: "";
  width: 15%; height: 15%;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, #1a1a1c 0 1px, #2c2c30 1px 1.6px),
    #111;
  box-shadow:
    inset 0 1px 2px rgba(0,0,0,.95),
    0 0 0 1.5px #6d7077,
    0 0 0 2.5px #d6d8dc,
    0 1px 0 2.5px rgba(255,255,255,.4);
}
.btn:active .cap, .btn.pressed .cap {
  transform: scale(.94) translateY(1px);
  filter: brightness(.92);
  box-shadow:
    0 1px 2px rgba(0,0,0,.9),
    inset 0 -1px 3px rgba(0,0,0,.4),
    inset 0 3px 5px rgba(0,0,0,.35),
    0 0 0 1px rgba(0,0,0,.5);
}
.btn:focus-visible { outline: 2px solid var(--engrave); outline-offset: 4px; }
.btn-main { width: var(--main); height: var(--main); }
.btn-share { width: var(--share); height: var(--share); }
.btn-share svg { width: 46%; height: 46%; }
.btn-share svg path, .btn-share svg circle {
  fill: none; stroke: #3b3d42; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.7));
}

/* Letztes Bild als kleines Rückschau-Fenster, wie eine versenkte Plakette */
.thumb {
  -webkit-appearance: none; appearance: none;
  width: clamp(36px, 9dvh, 52px); aspect-ratio: 3 / 2;
  height: auto;
  padding: 0; border: 0; border-radius: 3px;
  background: #0c0c0d;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.95), 0 1px 0 rgba(255,255,255,.12), 0 0 0 1px #2a292e;
  overflow: hidden;
  cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Textknöpfe (gravierte Beschriftung) ---------- */
.engraved {
  -webkit-appearance: none; appearance: none;
  background: rgba(20,19,23,.55);
  border: 1px solid rgba(233,228,216,.18);
  border-radius: 999px;
  padding: .7em 1.2em;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--engrave);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.engraved:active { background: rgba(233,228,216,.12); }
.engraved:focus-visible { outline: 2px solid var(--engrave); outline-offset: 2px; }
.engraved.danger { color: var(--danger); }
.engraved:disabled { opacity: .4; }

/* ---------- Einschalter ---------- */
.power {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  padding: 16px;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(255,255,255,.05), transparent 60%),
    var(--leather-texture),
    var(--leather);
}
.power-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; max-width: 420px; text-align: center; }
.brand { font-size: 28px; font-weight: 500; letter-spacing: .6em; padding-left: .6em; text-transform: uppercase; }
.engraved-label { font-size: 11px; letter-spacing: .3em; padding-left: .3em; text-transform: uppercase; color: var(--engrave-dim); }
.power-error { font-size: 14px; line-height: 1.5; color: var(--danger); margin: 0; }

/* ---------- Galerie ---------- */
.gallery {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--ground);
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.g-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px;
  background:
    var(--leather-texture),
    var(--leather);
  box-shadow: 0 4px 12px rgba(0,0,0,.6);
  position: relative; z-index: 1;
}
.g-title { font-size: 12px; letter-spacing: .3em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-grid {
  flex: 1; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px;
  padding: 4px 16px 16px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}
.g-grid button {
  padding: 0; border: 0; background: #111; cursor: pointer;
  aspect-ratio: 3 / 2; overflow: hidden;
}
.g-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-empty { margin: auto; color: var(--engrave-dim); letter-spacing: .2em; text-transform: uppercase; font-size: 12px; }

.viewer {
  position: absolute; inset: 0; z-index: 2;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  touch-action: pan-y;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.v-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 48px; height: 72px; border: 0; background: transparent;
  font-size: 40px; color: rgba(233,228,216,.7); cursor: pointer;
}
.v-prev { left: max(4px, env(safe-area-inset-left, 0px)); }
.v-next { right: max(4px, env(safe-area-inset-right, 0px)); }
.v-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(transparent, rgba(0,0,0,.75));
}
.v-meta { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--engrave-dim); }
.v-actions { display: flex; gap: 8px; }

/* ---------- Dialog & Hinweise ---------- */
.confirm {
  border: 1px solid rgba(233,228,216,.15);
  border-radius: 12px;
  padding: 22px;
  max-width: min(360px, calc(100vw - 32px));
  background: var(--leather-texture), var(--leather);
  color: var(--engrave);
  text-align: center;
}
.confirm::backdrop { background: rgba(0,0,0,.6); }
.confirm p { margin: 0 0 18px; font-size: 15px; letter-spacing: .04em; }
.confirm-actions { display: flex; justify-content: center; gap: 10px; }

.toast {
  position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top, 0px)); z-index: 40;
  transform: translate(-50%, -8px);
  max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 999px;
  background: rgba(20,19,23,.9); border: 1px solid rgba(233,228,216,.15);
  font-size: 13px; letter-spacing: .04em;
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Hochkant: Streifen unten ----------
   Von links nach rechts: Galerie, Auslöser, Filterrad. Quer gehalten (Oberkante links)
   liegt das Rad damit oben, die Galerie unten – wie im Querformat-Layout. */
@media (orientation: portrait) {
  .camera { flex-direction: column; }
  .viewfinder { padding-left: 0; padding-top: env(safe-area-inset-top, 0px); }
  .strip {
    flex: 0 0 auto;
    flex-direction: row-reverse;
    padding: 18px 28px max(16px, env(safe-area-inset-bottom, 0px));
    box-shadow: inset 0 6px 10px -4px rgba(0,0,0,.9), inset 0 0 40px rgba(0,0,0,.6);
  }
  :root { --size: clamp(58px, 18vw, 100px); }
  .look-name { font-size: 13px; }
  /* Share-Auslöser links neben dem großen, leicht nach unten versetzt */
  .shutters { flex-direction: row-reverse; align-items: center; gap: calc(var(--share) * .3); }
  .shutters .btn-share { margin-top: 0; transform: translateY(calc(var(--main) * .3)); }
  .thumb { width: clamp(40px, 12vw, 60px); }
}

/* ---------- Haltung: Knöpfe bleiben, Beschriftungen drehen sich ----------
   --turn kommt aus dem Lagesensor (app.js): 90deg = Oberkante zeigt nach links,
   -90deg = nach rechts. Gedreht wird jeweils auf der Stelle, das Layout bleibt. */
:root { --turn: 0deg; }
.scale-letter, .look-name, .btn-share svg, .thumb {
  transition: transform .3s cubic-bezier(.3,1.2,.5,1);
}
.btn-share svg { transform: rotate(var(--turn)); }
.thumb { transform: rotate(var(--turn)); }

/* Leiste am eingefrorenen Bild liegt immer an der Unterkante aus Sicht des Nutzers */
html.turn-left .frozen-bar, html.turn-right .frozen-bar {
  right: auto; bottom: auto; top: 0; left: 0;
  width: 100cqh;
  transform-origin: 0 0;
}
html.turn-left .frozen-bar  { transform: rotate(90deg) translateY(-100%); }
html.turn-right .frozen-bar { transform: translate(100cqw, 100cqh) rotate(-90deg) translateY(-100%); }

@media (prefers-reduced-motion: reduce) {
  .dial { transition: none; }
  .flash.go { animation-duration: 1ms; }
}
