/*
  gallery.css — styling for the shipped-texture gallery.

  Carries over textureHouse's look: the Fistalle header plate, the inset-bevel tiles, the
  coloured licence outline, the same five tier colours, and the light blue "bumpy scales"
  ground (assets/site/wallpapers/ltblubumpyscales-web.jpg on body). One deliberate departure.

  TILES CARRY LABELS. The collection's tiles are bare because a picture in a folder called
  STONE/ has already told you what it is. Here the filename IS the finding — it is what the
  .gltf references, what you grep for, and (when it differs from the collection's name for
  the same image) the thing that made the audit and the build drift apart in the first
  place. So every tile states its shipped name, and badges anything you would otherwise
  have to look up: that it needs replacing, that it has no entry, what it used to be
  called, that its tier was inferred rather than matched, that no model uses it any more.
*/

@font-face {
    font-family: 'Fistalle';
    src: url('../../assets/fonts/Fistalle.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --ground: #1b1d21;
    --ink: #e6e6e6;
    --dim: rgba(255, 255, 255, .55);
    --plate: rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; -webkit-font-smoothing: none; -moz-osx-font-smoothing: unset; font-smooth: never; }

body {
    margin: 0;
    padding: 0 12px 60px;
    background-color: var(--ground);
    background-image: url("../../assets/site/wallpapers/ltblubumpyscales-web.jpg");
    background-size: 0.175pc;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    text-rendering: optimizeSpeed;
}

/* ---- Header ----------------------------------------------------------- */

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

.header-title {
    color: #fffb00;
    filter: sepia(.85);
    margin: 1pc 0;
    font-size: 2.5em;
    font-family: Fistalle, sans-serif;
    font-weight: 500;
    word-spacing: .5em;
    letter-spacing: .05em;
    padding: .5rem 1rem;
    box-shadow: 0 0 .5pc 0 #000 inset;
    border-bottom: 8px inset rgba(255, 255, 255, .2);
    border-left: 8px inset rgba(255, 255, 255, .2);
    border-right: 8px inset rgba(0, 0, 0, .2);
    border-top: 8px inset rgba(0, 0, 0, .2);
    transform: scaleX(.9);
    display: inline-block;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #ffee00, -1px 1px 0 #ffee00;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-top: 1pc;
}

.room-links, .source-links { display: flex; flex-direction: column; align-items: flex-start; }

.room-links a, .source-links a {
    font-size: .7em;
    background: var(--plate);
    text-decoration: none;
    padding: 2px 4px;
}
.room-links a { color: #ffee00; }
.source-links a { color: #fff; }
.room-links a:hover, .source-links a:hover { text-decoration: underline; }
.room-links a.current { color: #fff; background: rgba(0, 0, 0, .8); }

#source-note {
    font-size: .7em;
    color: var(--dim);
    padding: 4px 0 0;
}

/* ---- Controls --------------------------------------------------------- */

.controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 4px 0 0;
    font-size: .75em;
    color: var(--dim);
}

.controls input[type="search"] {
    background: #000;
    border: 1px solid #444;
    color: var(--ink);
    font: inherit;
    padding: 4px 8px;
    min-width: 220px;
}
.controls input[type="search"]:focus { outline: 1px solid #ffee00; }
.controls label { display: flex; align-items: center; gap: 5px; cursor: pointer; }

/* ---- Grid ------------------------------------------------------------- */

.container { display: flex; justify-content: flex-start; align-items: flex-start; flex-wrap: wrap; }

h2.folder-heading {
    width: 100%;
    text-align: left;
    font-size: 1.5em;
    margin: 30px 0 10px;
    font-family: Fistalle, sans-serif;
    font-weight: 400;
    word-spacing: .5em;
    color: #fff;
    text-shadow: .5px .5px 0 #fcfae2, -1px -1px 0 #000, 1px -1px 0 #000, -.5px .5px 0 #fffcd4;
}

.newWorld {
    display: flex;
    flex-direction: column;
    width: 192px;
    margin: 10px;
    flex: 0 0 auto;
    position: relative;
    outline: 3px solid transparent;
    outline-offset: 2px;
}

.newWorld.lic-clear       { outline-color: #3fb950; }
.newWorld.lic-conditional { outline-color: #d29922; }
.newWorld.lic-unknown     { outline-color: #db6d28; }
.newWorld.lic-unverified  { outline-color: #8b949e; }
.newWorld.lic-replace     { outline-color: #f85149; }

/* A <div> since the tile stopped being a download link — the dialog owns the download now,
   and it only ever offers a home-made original. So the pointer has to be asked for. */
.imgWrap {
    position: relative;
    display: block;
    width: 192px;
    height: 192px;
    cursor: pointer;
}
.imgWrap:hover { filter: drop-shadow(0 0 3px #000); }

.imgWrap::after {
    content: "";
    position: absolute;
    inset: 0;
    border-bottom: 2px inset rgba(0, 0, 0, .7);
    border-left: 2px inset rgba(0, 0, 0, .6);
    border-right: 2px inset rgba(255, 255, 255, .7);
    border-top: 2px inset rgba(255, 255, 255, .5);
}

.newWorld img,
.newWorld canvas.ktx2 {
    width: 100%;
    height: 100%;
    /* Stretched to the square tile, whatever the real ratio — the size label states the
       true dimensions, so squaring them up costs no information and keeps the grid even. */
    object-fit: fill;
    display: block;
    background: #000;
}

/* A .ktx2 tile is a <canvas> that ktx2Preview.js fills in on scroll (no <img> can show one).
   Two differences from an <img>: it starts EMPTY, so the checker gives it a visible "not yet
   decoded" state rather than a black square; and half the library is alpha cutouts, so the
   checker also shows through the transparency instead of compositing it onto black. */
.newWorld canvas.ktx2 {
    background-color: #1b1b1b;
    background-image:
        linear-gradient(45deg, #262626 25%, transparent 25%, transparent 75%, #262626 75%),
        linear-gradient(45deg, #262626 25%, transparent 25%, transparent 75%, #262626 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
}

.size-label {
    position: absolute;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, .7);
    color: #fff;
    font-size: .6em;
    padding: 2px 4px;
    pointer-events: none;
    z-index: 1;
}

.name-label {
    font-size: .62em;
    color: var(--ink);
    background: rgba(0, 0, 0, .45);
    padding: 3px 4px;
    /* Long ingest names must not widen the tile; they wrap and the tooltip has the whole
       thing. break-all rather than a hard truncation — a name you can only half read is
       not much better than one you cannot read. */
    word-break: break-all;
    line-height: 1.3;
}

.use-label {
    font-size: .58em;
    color: var(--dim);
    background: rgba(0, 0, 0, .3);
    padding: 2px 4px;
}

/* ---- Badges ----------------------------------------------------------- */

.badges {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    z-index: 2;
    pointer-events: none;
    max-width: 100%;
}

.badge {
    font: bold 9px/1.2 Arial, Helvetica, sans-serif;
    letter-spacing: .5px;
    padding: 3px 5px;
    color: #fff;
    max-width: 100%;
    word-break: break-all;
}

.b-replace  { background: #f85149; }
.b-noentry  { background: #6e7681; }
.b-renamed  { background: #1f6feb; font-weight: normal; letter-spacing: 0; }
.b-inferred { background: #8957e5; }
.b-orphan   { background: #000; border: 1px solid #f0883e; color: #f0883e; }

/* ---- Dialog ----------------------------------------------------------- */

#texture-dialog {
    position: absolute;
    z-index: 1000;
    display: none;
    background: rgba(0, 0, 0, .9);
    border: 1px solid #444;
    max-width: 380px;
}

#dialog-filename {
    font-size: .7em;
    color: #ffee00;
    padding: 5px 6px;
    word-break: break-all;
    border-bottom: 1px solid #333;
}

#dialog-body {
    font-size: .68em;
    color: #ccc;
    padding: 5px 6px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.45;
    border-bottom: 1px solid #333;
}

#texture-dialog button {
    font-size: .7em;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    border: none;
    width: 100%;
    text-align: left;
    padding: 4px 6px;
    display: block;
    cursor: pointer;
    font-family: inherit;
}
#texture-dialog button:hover { background: #222; }

.linked-source-btn { text-decoration: underline; }
#dialog-links .linked-source-btn { padding-left: 14px; }
.linked-source-btn:hover { color: #ffee00; }
.homemade-source-btn { color: #ffd700; text-shadow: 0 0 8px #ffd700, 0 0 16px #ffa500; cursor: default; }
.custom-source-btn { cursor: default; }

/* ---- Empty state ------------------------------------------------------ */

.empty-note {
    width: 100%;
    color: #fff;
    font-size: .8em;
    line-height: 1.6;
    background: rgba(0, 0, 0, .5);
    padding: 16px;
    margin: 40px 0;
}
.empty-note code { color: #ffee00; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ── textureHouse additions ────────────────────────────────────────────────────
   Copied from pages/textureHouse/gallery.css and extended, deliberately NOT linked
   to it: textureHouse is the gallery for the flat assets/textures/ folder, and that
   folder is being deleted at the end of the migration. This page has to outlive it. */

/* Group headings — HOME MADE and EVERYTHING ELSE, this gallery's primary structure, where
   v1's was licence tier. The class is still .cat-heading because the applyFilters() sweep
   that hides an empty heading walks it by name and there is nothing to gain from renaming
   it in three files. */
.cat-heading {
    width: 100%;
    margin: 26px 0 8px;
    padding: 0 0 4px;
    border-bottom: 1px solid #333;
    font-size: 15px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #ffee00;
}
.cat-heading .cat-count { color: #8b949e; letter-spacing: 0; text-transform: none; margin-left: 8px; }

/* The home-made group is the one with real images under it; give it the accent the rest of
   the page uses for "yours". */
.cat-heading.is-homemade-heading { color: #58a6ff; }

/* "working" is the absence of a source, not a source — the same red the NO SOURCE badge
   uses, because every tile under it carries one. It sorts last, so this is the colour the
   page ends on for as long as anything is unrecorded. */
.cat-heading.is-working-heading { color: #f85149; }

/* One sentence per heading saying what the group means. Lower case and unspaced, so it
   reads as prose against the tracked-out uppercase heading rather than competing with it. */
/* The one badge that matters here. A texture with no sources.json entry is the whole
   reason this page exists, so it is louder than anything else on the tile. */
.b-nosource { background: #f85149; }

/* No badge marks a tile that HAS its original — see the note in gallery.js. Under the "home made"
   heading that is every tile, and a badge on every tile is a label, not a signal. The blue frame
   below is what carries it, quietly. */

/* UNFILED — sitting in working/ because its SketchUp material name was missing a category
   prefix, an "@" source, or both. Outlined rather than filled: it is a note about the
   naming, not about the texture, and it should not shout over NO SOURCE. */
.b-working { background: #000; border: 1px solid #8b949e; color: #8b949e; }

/* A tile showing a real image gets the blue edge the badge uses, so the two groups stay
   distinguishable after you scroll past the heading — and when "group by home made" is
   switched off, which is the only thing left saying which is which. */
.newWorld.has-original .imgWrap::after { border-color: rgba(31, 111, 235, .85); }

/* The path prefix is dimmed so the eye lands on the filename, which is what you grep
   for — but the category stays visible, because a texture in the wrong folder is a
   wrong footstep sound later. */

/* The provenance line under each tile, mirroring .use-label's weight. */
.src-label {
    display: block;
    padding: 1px 4px 0;
    font-size: 10px;
    color: #8b949e;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.src-label.is-missing { color: #f85149; }
.src-label.is-homemade { color: #58a6ff; }
