/* Shared tile + appearance-editor styles, used by index.html (dashboard) and
   admin.html (predefined tiles). Relies on the theme tokens both pages define
   (--surface, --border, --text, --muted, --accent, --danger, --mono, --shadow).
   Served with Cache-Control: no-store, like the pages themselves.

   Tile rules are scoped to .f-links .chip: admin.html has its own unrelated
   .chip (a small mono pill), so a bare .chip selector would collide. Any
   container of tiles must carry the f-links class. */

/* ---------- Windows-Phone-style link tile ---------- */
/* A container may set --tile to change the base square (the dashboard uses the
   100px default; the quick-add strip shrinks it). Long titles widen a tile in
   20% steps via --grow, set from JS. */
.f-links .chip {
  --tile-c: #6b7280;
  position: relative; display: block; overflow: hidden;
  flex: 0 0 auto;                        /* never squashed by a tight flex row */
  width: calc(var(--tile, 100px) * var(--grow, 1)); height: var(--tile, 100px);
  background: var(--tile-c);
  border: 0; padding: 0;                 /* beat page-level .chip styles (admin) */
  font-family: var(--ui, system-ui, sans-serif); font-size: 12px;
  border-radius: 2px;                    /* Metro tiles are all but sharp */
  text-decoration: none; color: #fff;
  user-select: none; transition: transform .12s, opacity .12s;
  cursor: pointer;
}
.f-links .chip:hover { transform: scale(.96); }   /* the Metro press-in feel */
.f-links .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* picture layer, faded together with the tile's transparency */
.f-links .chip::before {
  content: ""; position: absolute; inset: 0;
  background-image: var(--tile-img, none); background-size: cover; background-position: center;
  opacity: var(--tile-img-a, 1);
}
/* frame layer: a single inset shadow, above the picture, no layout shift */
.f-links .chip::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  box-shadow: inset 0 0 0 var(--tile-frame-w, 0) var(--tile-frame-c, transparent);
}
.f-links .chip .mark {
  position: absolute; inset: 0 0 18px; display: grid; place-items: center;
  color: rgba(255, 255, 255, .88); font-weight: 700; font-size: 24px;
}
.f-links .chip[data-img] .mark { display: none; }   /* the picture is the visual */
.f-links .chip .label {
  position: absolute; left: 8px; right: 6px; bottom: 5px; z-index: 1;
  font-family: var(--tl-font, inherit); font-size: var(--tl-size, 12px);
  font-weight: var(--tl-weight, 600); font-style: var(--tl-style, normal);
  color: var(--tl-color, #fff); line-height: 1.25; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.f-links .chip[data-img] .label { text-shadow: 0 1px 2px rgba(0, 0, 0, .65); }
.f-links .chip .remove {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; z-index: 3;
  border-radius: 50%; border: 1px solid var(--border); background: var(--danger);
  color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
  display: none; place-items: center; padding: 0;
}

/* ---------- Appearance popover ---------- */
/* Fixed-position and parented to <body> so no ancestor's overflow clips it. */
.pop {
  position: fixed; z-index: 80;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  box-shadow: var(--shadow); padding: 10px;
  max-height: calc(100vh - 16px); overflow-y: auto;   /* the link editor can outgrow small windows */
}
.pop.style { width: 258px; }
.pop-grid { display: grid; grid-template-columns: repeat(4, 26px); gap: 7px; }
.pop-grid button { width: 26px; height: 26px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.pop-grid button[aria-pressed="true"] { border-color: var(--text); }
.pop-sec { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border); }
.pop-sec:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.pop-sec .sec-h { margin: 0 0 7px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.pop-row { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.pop-row > label { flex: 0 0 76px; font-weight: 600; }
.pop-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.pop-row select, .pop-row input[type="number"], .pop-row input[type="text"],
.pop-row input[type="url"], .pop-row input[type="file"] {
  flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font: inherit; font-size: 12px; padding: 3px 6px;
}
.pop-row input[type="file"] { font-size: 11px; }
.pop-row input[type="file"]::file-selector-button {
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px;
  color: var(--muted); font: inherit; font-size: 11px; font-weight: 650; cursor: pointer;
  padding: 2px 7px; margin-right: 7px;
}
.pop-row input[type="color"] { width: 32px; height: 24px; padding: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; flex: 0 0 auto; }
.pop-row input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); flex: 0 0 auto; }
.pop-row .pval { font-family: var(--mono); font-size: 10.5px; min-width: 34px; text-align: right; flex: 0 0 auto; }
.pop-row.off { opacity: .45; pointer-events: none; }
.pop-mini, .pop-reset {
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font: inherit; font-size: 11px; font-weight: 650; cursor: pointer; padding: 2px 8px;
}
.pop-mini:hover, .pop-reset:hover { color: var(--text); border-color: var(--accent); }
.pop-reset { display: block; width: 100%; margin-top: 10px; padding: 4px 8px; }
