/* FREEFRAMES – design follows the logo: warm paper, charcoal frames, one blue corner. */
:root {
  --paper: #F2F3F0;
  --paper-2: #E9EBE6;
  --surface: #FAFAF8;
  --ink: #1E2024;
  --ink-2: #4A4E57;
  --muted: #6E737C;
  --line: #D6D9D2;
  --blue: #1F3FA0;
  --blue-soft: #DCE3F5;
  --on-blue: #FFFFFF;
  --danger: #B42318;
  --radius: 2px;
  --gap: 16px;
  --card-min: 240px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --paper: #15171C;
  --paper-2: #1C1F26;
  --surface: #1A1D24;
  --ink: #EEEFF1;
  --ink-2: #C5C9D1;
  --muted: #8A909C;
  --line: #2C313B;
  --blue: #8CA6F5;
  --blue-soft: #1E2A4A;
  --on-blue: #0B1020;
  --danger: #F97066;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.15; letter-spacing: -.02em; }
h1 { font-size: clamp(1.8rem, 3.6vw, 2.8rem); font-weight: 600; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 .75em; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.noscript { padding: 24px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 200; }
.skip-link:focus { left: 8px; }
[hidden] { display: none !important; }

/* ---------- intro: the mark forms, then the wordmark wipes in, then the screen lifts ---------- */
.intro {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: var(--paper); cursor: pointer;
  transition: transform 1s var(--ease), opacity .7s ease, visibility .7s;
}
.intro > img { position: absolute; }
.intro__mark { width: min(170px, 38vw); animation: mark-in 1.1s var(--ease) .1s both, mark-out .55s var(--ease) 1.55s forwards; }
.intro__word { width: min(460px, 78vw); clip-path: inset(0 100% 0 0); animation: word-in 1s var(--ease) 1.6s forwards; }
.intro.is-done { transform: translateY(-100%); opacity: 0; visibility: hidden; pointer-events: none; }
@keyframes mark-in {
  0%   { opacity: 0; transform: scale(.35) rotate(-120deg); }
  65%  { opacity: 1; transform: scale(1.06) rotate(6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes mark-out { to { opacity: 0; transform: translateX(-30px) scale(.92); } }
@keyframes word-in { to { clip-path: inset(0 0 0 0); } }

/* ---------- header: logo left, search centred, two icons right ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar__inner {
  position: relative; display: grid; grid-template-columns: 1fr minmax(0, 620px) 1fr;
  align-items: center; gap: 24px; max-width: 1440px; margin: 0 auto; padding: 14px 24px;
}
.brand { justify-self: start; display: inline-flex; }
.brand__logo { height: 38px; width: auto; transition: transform .4s var(--ease); }
.brand:hover .brand__logo { transform: translateX(2px) scale(1.04); }
.topbar__actions { justify-self: end; display: flex; gap: 6px; }

.search {
  position: relative; width: 100%; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 14px; height: 46px;
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease), transform .4s var(--ease);
}
.search:focus-within { border-color: var(--blue); transform: scale(1.01); box-shadow: 0 0 0 4px var(--blue-soft); }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 15px; outline: none; padding: 0;
}
.search input::placeholder { color: var(--muted); }
.search__clear { border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; }
.history {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--line); padding: 6px; animation: drop .3s var(--ease);
}
.history button {
  display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink);
  padding: 9px 10px; cursor: pointer; font: inherit;
}
.history button:hover { background: var(--paper-2); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid transparent;
  background: transparent; color: var(--ink); cursor: pointer; border-radius: var(--radius);
  transition: border-color .25s, transform .3s var(--ease), background .25s;
}
.icon-btn:hover { border-color: var(--line); background: var(--surface); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .ico { width: 19px; height: 19px; }
.avatar { width: 26px; height: 26px; display: grid; place-items: center; background: var(--blue); color: var(--on-blue); font-size: 13px; font-weight: 600; }

/* ---------- buttons, chips, badges ---------- */
.btn {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border: 1px solid var(--ink); border-radius: var(--radius); background: transparent; color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: color .35s var(--ease), transform .3s var(--ease);
}
.btn::before {
  content: ""; position: absolute; inset: 0; background: var(--ink); transform: scaleX(0); transform-origin: left;
  transition: transform .45s var(--ease); z-index: -1;
}
.btn:hover { color: var(--paper); }
.btn:hover::before { transform: scaleX(1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .ico { width: 16px; height: 16px; }
.btn--primary { background: var(--blue); border-color: var(--blue); color: var(--on-blue); }
.btn--primary::before { background: var(--ink); }
.btn--primary:hover { color: var(--paper); }
.btn--danger { color: var(--danger); border-color: var(--danger); }
.btn--danger::before { background: var(--danger); }
.btn--danger.solid { background: var(--danger); color: #fff; }
.chip {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--line); background: var(--surface);
  text-decoration: none; font-size: .88rem; color: var(--ink-2); border-radius: var(--radius);
  transition: border-color .25s, color .25s, transform .3s var(--ease);
}
.chip:hover { border-color: var(--blue); color: var(--blue); transform: translateY(-2px); }
.badge { display: inline-block; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; padding: 3px 7px; background: var(--paper-2); color: var(--ink-2); }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px 24px 56px; outline: none; }
.page-head { margin-bottom: 22px; }
.page-head p { color: var(--muted); }
.block { margin: 48px 0; }
.block__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.block__head a { color: var(--muted); font-size: .9rem; text-decoration: none; }
.block__head a:hover { color: var(--blue); }

.hero { text-align: center; padding: 56px 0 24px; animation: rise .9s var(--ease) both; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); letter-spacing: -.035em; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 520px; margin: 0 auto; }
.hero__chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 26px; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cat-tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 110px; padding: 16px;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-decoration: none;
  transition: background .3s var(--ease), padding .4s var(--ease);
}
.cat-tile:hover { background: var(--surface); padding-left: 22px; }
.cat-tile::before { content: ""; position: absolute; left: 0; top: 0; width: 3px; height: 0; background: var(--blue); transition: height .45s var(--ease); }
.cat-tile:hover::before { height: 100%; }
.cat-tile span:last-child { color: var(--muted); font-size: .85rem; }

.results__head { margin-bottom: 18px; }
.notice { padding: 10px 14px; border-left: 3px solid var(--blue); background: var(--blue-soft); font-size: .9rem; margin-bottom: 18px; animation: rise .5s var(--ease) both; }
.error-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 16px; }
.error-box p { margin: 0; color: var(--muted); }
.empty { padding: 64px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--line); }
.empty h2 { color: var(--ink); }
.loadmore { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 32px; }

/* ---------- gallery: framed images, blue corner brackets on hover ---------- */
.grid--masonry { column-width: var(--card-min); column-gap: var(--gap); }
.grid--masonry .card { break-inside: avoid; margin-bottom: var(--gap); }
.grid--mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: var(--gap); }

.card {
  position: relative; background: var(--surface); padding: 6px; border: 1px solid var(--line);
  animation: rise .7s var(--ease) both;
  transition: transform .5s var(--ease), border-color .3s, box-shadow .5s var(--ease);
}
.card:hover { transform: translateY(-5px); border-color: var(--ink); box-shadow: 0 18px 36px -18px rgba(0,0,0,.35); }
.card::before, .card::after {
  content: ""; position: absolute; width: 22px; height: 22px; pointer-events: none; z-index: 2; opacity: 0;
  transition: transform .5s var(--ease), opacity .3s;
}
.card::before { top: -1px; left: -1px; border-top: 3px solid var(--blue); border-left: 3px solid var(--blue); transform: translate(-6px,-6px); }
.card::after { bottom: -1px; right: -1px; border-bottom: 3px solid var(--blue); border-right: 3px solid var(--blue); transform: translate(6px,6px); }
.card:hover::before, .card:hover::after { opacity: 1; transform: none; }

.card__media { display: block; width: 100%; padding: 0; border: 0; background: var(--paper-2); cursor: zoom-in; overflow: hidden; }
.card__media img { width: 100%; height: auto; min-height: 90px; object-fit: cover; animation: fade-scale .9s var(--ease) both; transition: transform .8s var(--ease), filter .6s; }
.card:hover .card__media img { transform: scale(1.05); filter: saturate(1.08); }
.card__empty { display: grid; place-items: center; min-height: 120px; font-size: .85rem; color: var(--muted); padding: 12px; text-align: center; }
.card__foot { position: absolute; left: 12px; bottom: 12px; right: 12px; display: flex; gap: 6px; align-items: center; pointer-events: none; }
.card__foot .muted { background: rgba(20,22,27,.78); color: #fff; padding: 2px 7px; font-size: .72rem; }
.card__foot .badge { background: rgba(250,250,248,.92); color: #1E2024; }
.fav {
  position: absolute; top: 12px; right: 12px; z-index: 3; width: 36px; height: 36px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: rgba(20,22,27,.7); color: #fff; transition: transform .35s var(--ease), background .3s;
}
.fav .ico { width: 17px; height: 17px; }
.fav:hover { transform: scale(1.12); }
.fav.is-on { background: var(--blue); }
.fav.is-on .ico { animation: pop .5s var(--ease); }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }

.skeleton {
  border: 1px solid var(--line); background: linear-gradient(100deg, var(--surface) 30%, var(--paper-2) 50%, var(--surface) 70%);
  background-size: 250% 100%; animation: shimmer 1.4s linear infinite;
}
.grid--masonry .skeleton { margin-bottom: var(--gap); break-inside: avoid; }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -150% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fade-scale { from { opacity: 0; transform: scale(1.06); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

/* ---------- viewer ---------- */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: var(--radius); }
dialog::backdrop { background: rgba(14, 16, 20, .72); backdrop-filter: blur(3px); animation: fade-in .3s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.viewer { width: min(1180px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.viewer[open] { animation: dlg-in .45s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
.vw { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); }
.vw__media { background: var(--paper-2); display: grid; place-items: center; min-height: 260px; padding: 14px; }
.vw__media img { max-width: 100%; max-height: calc(100vh - 90px); height: auto; animation: fade-scale .7s var(--ease) both; }
.vw__info { padding: 22px; display: flex; flex-direction: column; gap: 14px; border-left: 1px solid var(--line); }
.vw__top { display: flex; justify-content: space-between; align-items: center; }
.vw__info h2 { font-size: 1.25rem; margin: 0; overflow-wrap: anywhere; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: .9rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.attr { font-size: .85rem; color: var(--muted); margin: 0; }
.usage { font-size: .85rem; color: var(--ink-2); margin: 0; padding: 10px 12px; border-left: 3px solid var(--blue); background: var(--paper-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags .chip { font-size: .8rem; padding: 4px 9px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.actions .btn { flex: 1 1 auto; }

/* ---------- dialogs ---------- */
.dialog { width: min(420px, calc(100vw - 24px)); padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.4); animation: dlg-in .4s var(--ease); }
.dlg { display: flex; flex-direction: column; gap: 14px; }
.dlg label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; color: var(--muted); }
.dlg input { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; transition: border-color .25s, box-shadow .25s; }
.dlg input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.form-error { color: var(--danger); font-size: .9rem; margin: 0; min-height: 1.2em; }
.switch { font-size: .9rem; color: var(--muted); }
.switch button { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; padding: 0; }

/* ---------- pages ---------- */
.panel { padding: 22px; border: 1px solid var(--line); background: var(--surface); margin-bottom: 24px; }
.panel.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.settings { display: grid; max-width: 680px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting small { color: var(--muted); display: block; }
.segmented { display: inline-flex; border: 1px solid var(--ink); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { padding: 7px 14px; cursor: pointer; color: var(--ink-2); font-size: .9rem; transition: background .25s, color .25s; }
.segmented input:checked + label { background: var(--ink); color: var(--paper); }
.segmented input:focus-visible + label { outline: 2px solid var(--blue); outline-offset: -2px; }
.profile-list { list-style: none; margin: 0; padding: 0; }
.profile-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }

/* ---------- footer, toasts ---------- */
.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.footer__inner { max-width: 1440px; margin: 0 auto; padding: 24px; }
.footer__nav { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-bottom: 12px; }
.footer__nav a { text-decoration: none; color: var(--ink-2); }
.footer__nav a:hover { color: var(--blue); }
.footer p { margin: 0; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 300; width: min(460px, calc(100vw - 24px)); }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; font-size: .9rem; border-left: 3px solid var(--blue); animation: toast-in .45s var(--ease); }
.toast--out { opacity: 0; transition: opacity .5s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  :root { --card-min: 150px; --gap: 10px; }
  .topbar__inner { grid-template-columns: 1fr auto; gap: 12px; padding: 10px 14px; }
  .brand__logo { height: 30px; }
  .search { grid-column: 1 / -1; order: 3; height: 42px; }
  main { padding: 18px 14px 40px; }
  .vw { grid-template-columns: 1fr; }
  .vw__info { border-left: 0; border-top: 1px solid var(--line); }
  .hero { padding-top: 28px; }
}

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

/* ---------- home: one quiet search field, centred ---------- */
body[data-route="home"] .topbar .search { visibility: hidden; }
.hero { padding: 88px 0 40px; }
.hero h1 { margin-bottom: 14px; }
.hero__search {
  position: relative; display: flex; align-items: center; gap: 10px; max-width: 680px; margin: 36px auto 0;
  background: var(--surface); border: 1px solid var(--line); padding: 8px 8px 8px 20px;
  transition: border-color .3s var(--ease), box-shadow .5s var(--ease), transform .5s var(--ease);
  animation: rise .9s .15s var(--ease) both;
}
.hero__search:focus-within { border-color: var(--blue); transform: translateY(-2px); box-shadow: 0 0 0 5px var(--blue-soft), 0 26px 60px -30px rgba(0,0,0,.5); }
.hero__search input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 17px; padding: 12px 0; outline: none;
}
.hero__search input::placeholder { color: var(--muted); }
.hero__search .btn { padding: 13px 24px; }

/* larger, more even gallery spacing */
.grid--mini { gap: 20px; }
.grid--masonry { column-gap: 20px; }
.grid--masonry .card, .grid--masonry .skeleton { margin-bottom: 20px; }

/* ---------- logo in dark mode: invert the dark shapes, keep the blue corner blue ---------- */
:root[data-theme="dark"] .brand__logo,
:root[data-theme="dark"] .hero__mark { filter: invert(1) hue-rotate(180deg); }

/* ---------- start page mark ---------- */
.hero__mark { width: 84px; height: auto; margin: 0 auto 26px; animation: mark-in 1s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  .intro__word { clip-path: none; }
  .intro__mark { animation: none; }
}
