/* =========================================================
   LOUIE'S GALLERY — Skinny Louie
   Proportions come from the design (1920px desktop / 11-column
   grid, mobile / 5-column grid). Everything scales with --cw.
   ========================================================= */

/* Two fonts only: Liberator (titles) and Roboto Mono (texts).
   Files in /fonts. Each block lists the formats it accepts; the browser
   uses the first one it finds. If Liberator can't load, Roboto Mono bold
   takes its place, scaled down ("Liberator Fallback") to keep the widths. */
@font-face {
  font-family: "Liberator";
  src: url("../fonts/Liberator-Medium.woff2") format("woff2"),
       url("../fonts/Liberator-Medium.otf") format("opentype");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "Roboto Mono";
  src: url("../fonts/RobotoMono-Regular.ttf") format("truetype"),
       url("../fonts/roboto-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Roboto Mono";
  src: url("../fonts/RobotoMono-SemiBold.ttf") format("truetype"),
       url("../fonts/roboto-mono-700.woff2") format("woff2");
  font-weight: 600 700;
  font-display: swap;
}
@font-face {
  font-family: "Liberator Fallback";
  src: url("../fonts/RobotoMono-SemiBold.ttf") format("truetype"),
       url("../fonts/roboto-mono-700.woff2") format("woff2");
  font-weight: 400 800;
  size-adjust: 77%;
  font-display: swap;
}

:root {
  --red: #911927;
  --red-dark: #6f1019;
  --pink: #d8acb0;
  --bg: #fcf8f8;
  --panel: #fffdfc;
  --veil: rgba(255, 253, 252, .74);

  --display: "Liberator", "Liberator Fallback", monospace;
  --mono: "Roboto Mono", ui-monospace, Menlo, monospace;

  /* grid */
  --cols: 11;
  --page-w: 100vw;                       /* set to the real width (no scrollbar) by app.js */
  --cw: calc(var(--page-w) / var(--cols));
  --ch: calc(var(--cw) * .6877);         /* 120 / 174.5 */
  --line: 1px;

  /* panel */
  --gutter: calc(var(--cw) * .195);      /* 34px @1920 */
  --pad: calc(var(--cw) * .19);          /* 33px @1920 */
  --gap: calc(var(--cw) * .17);          /* 30px between photos */

  /* section head */
  --head-pt: calc(var(--cw) * .36);
  --head-pb: calc(var(--cw) * .16);
  --head-indent: calc(var(--cw) * .34);

  /* type */
  --fs-logo: calc(var(--cw) * .33);
  --fs-title: calc(var(--cw) * .215);
  --fs-row: calc(var(--cw) * .185);
  --fs-folder: max(11px, calc(var(--cw) * .11));
  --fs-btn: calc(var(--cw) * .14);
  --icon: calc(var(--cw) * .215);
  --icon-sm: calc(var(--cw) * .15);

  /* components */
  --folder-w: calc(var(--cw) * .78);
  --wm-w: calc(var(--cw) * 2.8);         /* Skinny Louie watermark on the home */
  --rows-indent: calc(var(--cw) * .3);
  --row-h: calc(var(--cw) * .47);
  --row-gap: calc(var(--cw) * .063);
  --tile-border: max(1.5px, calc(var(--cw) * .013));
  --dlg-w: calc(var(--cw) * 2.12);
  --modal-w: calc(var(--cw) * 2.75);
}

@media (max-width: 767px) {
  :root {
    --cols: 5;
    --ch: calc(var(--cw) * .70);
    --gutter: calc(var(--cw) * .198);
    --pad: calc(var(--cw) * .19);
    --gap: calc(var(--cw) * .115);

    --head-pt: calc(var(--cw) * .3);
    --head-pb: calc(var(--cw) * .24);
    --head-indent: calc(var(--cw) * .05);

    --fs-logo: calc(var(--cw) * .235);
    --fs-title: max(13px, calc(var(--cw) * .17));
    --fs-row: max(13px, calc(var(--cw) * .18));
    --fs-folder: max(9px, calc(var(--cw) * .1));
    --fs-btn: max(12px, calc(var(--cw) * .165));
    --icon: calc(var(--cw) * .26);
    --icon-sm: max(16px, calc(var(--cw) * .2));

    --folder-w: calc(var(--cw) * .74);
    --wm-w: calc(var(--cw) * 3.6);
    --rows-indent: 0px;
    --row-h: calc(var(--cw) * .56);
    --row-gap: calc(var(--cw) * .07);
    --tile-border: 1.5px;
    --dlg-w: min(calc(var(--cw) * 2.75), 86vw);
    --modal-w: calc(var(--cw) * 3.95);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scrollbar-width: none;             /* scroll works, scrollbar hidden (Firefox, Chrome, Safari 18+) */
  -ms-overflow-style: none;
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, var(--red) var(--line), transparent var(--line)),
    linear-gradient(to bottom, var(--red) var(--line), transparent var(--line));
  background-size: var(--cw) var(--ch);
  background-position: 0 -1px;
  color: var(--red);
  -webkit-text-size-adjust: 100%;
  font-synthesis: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar { display: none; width: 0; height: 0; } /* older Safari / Chrome */

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  font-family: var(--display);
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.is-locked { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
svg { display: block; fill: currentColor; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-weight: 400; }

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- header ---------- */
.hdr {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  height: var(--ch);
  background: var(--bg);
  border-top: var(--line) solid var(--red);
  border-bottom: var(--line) solid var(--red);
}

.hdr__cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border-left: var(--line) solid var(--red);
  min-width: 0;
}

.hdr__logo {
  grid-column: span 3;
  justify-content: flex-start;
  padding: calc(var(--ch) * .06) 0 0 calc(var(--cw) * .2);
  font-size: var(--fs-logo);
  line-height: 1;
  letter-spacing: .005em;
  white-space: nowrap;
}


.hdr__btn { color: var(--pink); transition: color .15s; }
.hdr__btn[data-view="grid"] { justify-content: flex-end; padding-right: calc(var(--cw) * .11); }
.hdr__btn[data-view="list"] { justify-content: flex-start; padding-left: calc(var(--cw) * .09); }
.hdr__fav { justify-content: flex-end; padding-right: var(--gutter); } /* heart's right edge = panel's right edge */
.hdr__btn svg { width: var(--icon); height: var(--icon); }
.hdr__btn.is-active,
.hdr__fav { color: var(--red); }
@media (hover: hover) {
  .hdr__btn:hover { color: var(--red); }
  .hdr__fav:hover svg { transform: scale(1.08); }
}
.hdr__fav svg { transition: transform .15s; transform-origin: right center; width: calc(var(--icon) * 1.08); height: calc(var(--icon) * .95); }

@media (max-width: 767px) {
  .hdr__logo { grid-column: span 2; padding-left: calc(var(--cw) * .18); }
  .hdr__spacer { display: none; }
  .hdr__btn[data-view="grid"] { padding-right: calc(var(--cw) * .1); }
  .hdr__btn[data-view="list"] { padding-left: calc(var(--cw) * .2); }
}

/* ---------- panel ---------- */
.panel {
  position: relative;
  display: flow-root;
  margin: 0 var(--gutter);
  min-height: calc(100svh - var(--ch));
  padding: 0 var(--pad) calc(var(--pad) * 3);
  background: var(--panel);
  border-left: var(--line) solid var(--red);
  border-right: var(--line) solid var(--red);
}

.state {
  margin: 0;
  padding: calc(var(--cw) * 1.2) 0;
  text-align: center;
  font-size: var(--fs-title);
  letter-spacing: .02em;
}
.state small { display: block; margin-top: .8em; font-family: var(--mono); font-weight: 400; font-size: max(11px, .45em); }

/* ---------- section head ---------- */
.sec-head {
  display: flex;
  align-items: center;
  gap: calc(var(--cw) * .1);
  padding: var(--head-pt) 0 var(--head-pb) var(--head-indent);
}
.sec-head--split { justify-content: space-between; padding-right: 0; }
.sec-head__left { display: flex; align-items: center; gap: calc(var(--cw) * .1); min-width: 0; cursor: pointer; }
.sec-head__left .back svg { transition: transform .2s ease; }
@media (hover: hover) { .sec-head__left:hover .back svg { transform: translateX(-4px); } }
.sec-head--split .btn { font-size: max(13px, calc(var(--cw) * .165)); padding: .5em .7em .4em; }

.back {
  display: grid;
  place-items: center;
  flex: none;
  padding: calc(var(--fs-title) * .15) calc(var(--fs-title) * .1);
  margin-left: calc(var(--fs-title) * -.1);
}
.back svg { width: calc(var(--fs-title) * .48); height: auto; fill: currentColor; }

.sec-icon { flex: none; width: calc(var(--fs-title) * 1.3); margin-right: calc(var(--fs-title) * .15); }
.sec-icon--heart { width: calc(var(--fs-title) * 1.05); }

.sec-title {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 700;
  line-height: 1;
  padding-top: .08em;
  letter-spacing: .01em;
  white-space: nowrap;
}

/* ---------- folder icon ---------- */
.folder-svg { display: block; width: 100%; height: auto; overflow: visible; }
.folder-svg .f-back { fill: #77121e; }
.folder-svg .f-front { fill: #9b292c; }
.folder-svg path { stroke: #000; stroke-width: 6; stroke-linejoin: round; }

/* ---------- home: watermark + scattered folders ---------- */
.watermark {
  position: fixed;
  left: 50%;
  top: calc(var(--ch) + (100vh - var(--ch)) / 2);   /* centre of the area under the header */
  top: calc(var(--ch) + (100dvh - var(--ch)) / 2);
  width: var(--wm-w);
  height: auto;
  transform: translate(-50%, -50%);
  opacity: .3;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.folders { position: relative; z-index: 1; visibility: hidden; }
.folders.is-ready { visibility: visible; }
.folder {
  position: absolute;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: calc(var(--folder-w) * 1.9);
  margin-left: calc(var(--folder-w) * -.45);
  text-align: center;
}
.folder__icon { width: var(--folder-w); transition: transform .2s ease; }
.folder__label {
  margin-top: calc(var(--folder-w) * .14);
  font-size: var(--fs-folder);
  line-height: 1;
  letter-spacing: .02em;
  white-space: nowrap;
}
@media (hover: hover) {
  .folder:hover .folder__icon { transform: translateY(-4px) rotate(-3deg); }
}
.folder.is-dragging .folder__icon { transform: scale(1.08) rotate(-6deg); }

/* ---------- list rows (folders + photos) ---------- */
.rows {
  display: grid;
  gap: var(--row-gap);
  margin: 0 var(--rows-indent);
  padding: 0;
  list-style: none;
}
.rows--folders { margin-top: calc(var(--cw) * .38); }

.row {
  display: grid;
  grid-template-columns: calc(var(--row-h) * 1.15) 1fr auto;
  align-items: center;
  height: var(--row-h);
  border: var(--line) solid var(--red);
  background: var(--panel);
}
.row__thumb { display: grid; place-items: center; height: 100%; padding: 6px 0; }
.row__thumb img { max-height: calc(var(--row-h) - 14px); max-width: 80%; width: auto; height: auto; object-fit: contain; }
.row__name {
  min-width: 0;
  padding-left: calc(var(--cw) * .08);
  padding-top: .1em;
  font-size: var(--fs-row);
  line-height: 1;
  letter-spacing: .01em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__actions { display: flex; align-items: center; gap: calc(var(--cw) * .04); padding-right: calc(var(--cw) * .1); }

.row--folder {
  grid-template-columns: auto 1fr;
  padding-left: max(16px, calc(var(--cw) * .17));
  transition: background .15s, color .15s;
}
.row--folder .row__icon { width: calc(var(--row-h) * .5); }
.row--folder .row__name { padding-left: max(12px, calc(var(--cw) * .1)); }
.row--folder:focus-visible,
.row--folder:active { background: var(--red); color: var(--panel); outline: none; }
.row--folder:focus-visible .folder-svg path,
.row--folder:active .folder-svg path { fill: var(--red); stroke: var(--panel); }
@media (hover: hover) {
  .row--folder:hover { background: var(--red); color: var(--panel); }
  .row--folder:hover .folder-svg path { fill: var(--red); stroke: var(--panel); }
}

/* ---------- icon buttons ---------- */
.ico {
  display: grid;
  place-items: center;
  width: calc(var(--icon-sm) * 1.9);
  height: calc(var(--icon-sm) * 1.9);
  min-width: 36px;
  min-height: 36px;
  color: var(--red);
}
.ico svg { width: var(--icon-sm); height: var(--icon-sm); }
.ico .stroke { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .ico:hover { transform: scale(1.12); } }
.ico.pop svg { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.35); } }

/* ---------- masonry grid ---------- */
.masonry { display: flex; gap: var(--gap); align-items: flex-start; }
.masonry__col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

.tile {
  position: relative;
  margin: 0;
  border: var(--tile-border) solid var(--red);
  background: #f2e4e5;
  cursor: pointer;
  overflow: hidden;
}
.tile img { width: 100%; height: auto; opacity: 0; transition: opacity .35s ease; -webkit-user-drag: none; }
.masonry .tile { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tile.is-placeholder { opacity: .25; }
.tile--ghost {
  position: fixed;
  z-index: 60;
  margin: 0;
  pointer-events: none;
  border-color: var(--red);
  will-change: transform;
}
.tile--ghost img { opacity: 1; }
body.is-dragging { user-select: none; -webkit-user-select: none; }
body.is-dragging .tile__ov { opacity: 0 !important; visibility: hidden !important; }
.tile img.is-loaded { opacity: 1; }

.tile__ov {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--cw) * .02);
  background: var(--veil);
  opacity: 0;
  visibility: hidden;
  transition: opacity .18s ease, visibility .18s;
}
.tile.is-active .tile__ov { opacity: 1; visibility: visible; }
.tile.is-active { border-color: var(--pink); }
@media (hover: hover) {
  .tile:hover .tile__ov { opacity: 1; visibility: visible; }
  .tile:hover { border-color: var(--pink); }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  min-width: 4.2em;
  padding: .55em 1.1em .45em;
  font-size: var(--fs-btn);
  font-weight: 700;
  line-height: 1;
  letter-spacing: .02em;
  border: var(--line) solid var(--red);
  transition: background .15s, color .15s, opacity .15s;
}
.btn--line { color: var(--red); background: var(--panel); }
.btn--fill { color: var(--panel); background: var(--red); }
@media (hover: hover) {
  .btn--line:hover { background: var(--red); color: var(--panel); }
  .btn--fill:hover { background: var(--red-dark); border-color: var(--red-dark); }
}
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn svg { width: 1.15em; height: 1.15em; margin-top: -.1em; }
.btn .stroke { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- overlays ---------- */
.dim {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--veil);
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }

.dialog {
  width: var(--dlg-w);
  min-width: 250px;
  padding: calc(var(--cw) * .2) calc(var(--cw) * .15) calc(var(--cw) * .17);
  background: var(--panel);
  border: 2px solid var(--red);
  text-align: center;
  animation: rise .2s ease;
}
.dialog__title { margin: 0 0 calc(var(--cw) * .13); font-size: max(20px, calc(var(--cw) * .19)); line-height: 1; }
.dialog__btns { display: flex; justify-content: center; gap: calc(var(--cw) * .17); }
.dialog .btn { font-size: max(14px, calc(var(--cw) * .135)); min-width: 5.5em; padding: .7em 1em .55em; }

.modal {
  width: var(--modal-w);
  min-width: 290px;
  max-width: 92vw;
  padding: calc(var(--cw) * .2) calc(var(--cw) * .2) calc(var(--cw) * .23);
  background: var(--panel);
  border: max(3px, calc(var(--cw) * .017)) solid var(--red);
  text-align: center;
  animation: rise .2s ease;
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.modal__title { margin: 0; font-size: max(22px, calc(var(--cw) * .25)); line-height: 1; }
.modal__text {
  margin: calc(var(--cw) * .2) 0 calc(var(--cw) * .22);
  font-size: max(11px, calc(var(--cw) * .096));
  line-height: 1.25;
  letter-spacing: 0;
}
.br-m { display: none; }
.br-d { display: inline; }
.pill {
  display: block;
  width: 73%;
  margin: 0 auto calc(var(--cw) * .2);
  padding: calc(var(--cw) * .085) calc(var(--cw) * .17);
  font-size: max(16px, calc(var(--cw) * .098)); /* 16px min avoids iOS zoom */
  line-height: 1.2;
  color: var(--red);
  background: var(--panel);
  border: var(--line) solid var(--red);
  border-radius: 999px;
  outline: none;
}
.pill::placeholder { color: var(--red); opacity: .85; }
.pill:focus { box-shadow: 0 0 0 2px var(--pink); }
.pill.is-error { box-shadow: 0 0 0 2px var(--red); }
.btn--big { font-size: max(15px, calc(var(--cw) * .15)); padding: calc(var(--cw) * .045) calc(var(--cw) * .15) calc(var(--cw) * .035); }
.modal__status { margin: calc(var(--cw) * .12) 0 0; font-size: max(11px, calc(var(--cw) * .07)); }
.modal__status:empty { display: none; }

@media (max-width: 767px) {
  .dialog { min-width: 0; padding: 22px 16px 20px; border-width: 2px; }
  .dialog__title { font-size: max(18px, calc(var(--cw) * .2)); margin-bottom: 14px; }
  .dialog__btns { gap: 14px; }
  .dialog .btn { font-size: 13px; }
  .modal { padding: 36px 20px 32px; border-width: 3px; }
  .modal__title { font-size: calc(var(--cw) * .3); }
  .modal__text { font-size: max(11px, calc(var(--cw) * .15)); margin: 18px 0 26px; letter-spacing: .03em; }
  .br-m { display: inline; }
  .br-d { display: none; }
  .pill { width: 80%; margin-bottom: 18px; padding: .8em 1.4em; }
  .btn--big { font-size: calc(var(--cw) * .2); padding: .6em 1.4em .5em; }
  .modal__status { font-size: 11px; margin-top: 14px; }
}

/* ---------- hand cursor (js/cursor.js, desktop only) ---------- */
html.has-hand,
html.has-hand * { cursor: none !important; }
html.has-hand input:not([type="file"]):not([type="button"]):not([type="submit"]):not([type="checkbox"]):not([type="radio"]),
html.has-hand textarea { cursor: text !important; }

.hand {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  will-change: transform;
}
.hand.is-on { opacity: 1; }
.hand.is-text { opacity: 0; }
.hand__pointer {
  display: block;
  width: 32px;                      /* cursor size */
  max-width: none;
  height: auto;
  margin: -8.5px 0 0 -2px;           /* puts the fingertip on the click point */
  transform-origin: 2px 8.5px;       /* grows from the fingertip */
  transition: transform .18s ease;
}
.hand.is-hover .hand__pointer { transform: scale(1.12); }
.hand.is-down .hand__pointer { transform: scale(.94); }
.hand.is-hover.is-down .hand__pointer { transform: scale(1.05); }

/* open hand (img/grab.svg) over photos, grabbing hand (img/grabbing.svg) while
   dragging — both centred on the pointer */
.hand__open,
.hand__grab {
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;                      /* grabbing cursor size */
  max-width: none;                  /* the general img rule would shrink it to 0 here */
  height: auto;
  translate: -50% -50%;
  display: none;
}
.hand.is-grab .hand__pointer,
.hand.is-grabbing .hand__pointer,
.hand.is-grabbing .hand__open { display: none; }
.hand.is-grab:not(.is-grabbing) .hand__open,
.hand.is-grabbing .hand__grab { display: block; }

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