/* The look that site/glyph-editor.html and site/glyph-animator.html share: the site's
 * tokens, cards, the tool bar, the context bar and the shortcut help. */

:root {
  --bg: #f6f5f2; --panel: #fff; --ink: #16181c; --ink-soft: #565b66;
  --rule: #e2e0da; --accent: #b4530a; --off: #ecebe7;
  --cell-off: #dcdad3; --grid: rgba(255, 255, 255, .9); --grid-major: #fff;
  --focus: #1a5fb4;
  font-family: "IBM Plex Sans", system-ui, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0d0f; --panel: #141619; --ink: #e8e6e1; --ink-soft: #9aa0ab;
    --rule: #25282d; --accent: #ff9d3c; --off: #1d2024;
    --cell-off: #1d2024; --grid: rgba(255, 255, 255, .2); --grid-major: rgba(255, 255, 255, .45);
    --focus: #8ab4f8;
  }
}
* { box-sizing: border-box; }
body { margin: 0; padding: 16px; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
h1 { font-size: 1.3rem; margin: 0 0 .3rem; }
button, select, input { font: inherit; }
button { padding: .3rem .7rem; border: 1px solid var(--rule); border-radius: 6px; min-height: 36px;
         background: var(--panel); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button:disabled { opacity: .45; cursor: default; }
select, input[type=number], input[type=text] { padding: .25rem .4rem; border: 1px solid var(--rule); min-height: 36px;
         border-radius: 6px; background: var(--panel); color: var(--ink); }
input[type=number] { width: 4.8rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
label { display: inline-flex; gap: .3rem; align-items: center; }
.bar { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin: .5rem 0; }
.muted { color: var(--ink-soft); font-size: .9rem; }
canvas.px { image-rendering: pixelated; display: block; max-width: 100%; }

/* Cards: a panel with a heading; a <details> card folds. */
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; padding: .9rem 1rem;
        margin-bottom: 1rem; min-width: 0; }
.card > h2, .card > summary { font-size: 1rem; font-weight: 600; margin: 0 0 .6rem; }
details.card > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem; margin: 0; }
details.card > summary::before { content: "+"; font-family: ui-monospace, Consolas, monospace; color: var(--ink-soft); width: 1ch; }
details.card[open] > summary::before { content: "-"; }
details.card[open] > summary { margin-bottom: .6rem; }
details.card > summary::-webkit-details-marker { display: none; }

/* The tool bar: groups of icon buttons. It wraps on a narrow screen. */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 .5rem; position: relative; }
.tool-group { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg); }
.tool { width: 44px; height: 44px; min-height: 44px; padding: 5px; display: grid; place-items: center;
        border-color: transparent; background: transparent; color: var(--ink); }
.tool svg { display: block; }
.tool[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.tool:hover:not([aria-pressed="true"]) { border-color: var(--rule); }
.help-btn { border: 1px solid var(--rule); background: var(--panel); }

/* The context bar: the options of the active tool. */
.context-bar { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; min-height: 44px;
               padding: .35rem .5rem; margin: 0 0 .6rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg); }
.context-bar .ctx-name { font-weight: 600; margin-right: .3rem; }
.context-bar .hint { color: var(--ink-soft); font-size: .85rem; }
.context-bar input[type=range] { width: 7rem; }
.context-bar output { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; min-width: 4ch; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 34px; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.context-bar input[type=text] { width: 12rem; max-width: 100%; }
.context-bar .stamp-thumb { max-width: 160px; border: 1px solid var(--rule); }

/* The shortcut help: a panel under the tool bar, opened with ? or its button. */
.help-pop { position: absolute; z-index: 5; top: 100%; right: 0; margin-top: .3rem; width: min(26rem, calc(100vw - 32px));
            max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--rule);
            border-radius: 10px; padding: .8rem 1rem; box-shadow: 0 6px 24px rgb(0 0 0 / .25); }
.help-pop dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; margin: .6rem 0; font-size: .9rem; }
.help-pop dt { font-family: ui-monospace, Consolas, monospace; font-weight: 600; }
.help-pop dd { margin: 0; }

/* The drawing surface. */
.surface { display: block; touch-action: none; cursor: crosshair; height: auto; image-rendering: pixelated; }
.surface[data-tool="move"] { cursor: move; }

/* Fills. */
.fill-form, .fill-range .bar { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.fill-preview { display: flex; gap: .4rem; overflow-x: auto; padding: .5rem 0; }
.fill-note { margin: .3rem 0 0; }

/* The site's eyebrow (the way back to the index) and footer. */
.eyebrow { font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace; font-size: .72rem; letter-spacing: .14em;
           text-transform: uppercase; color: var(--accent); margin: 0 0 .6rem; }
.site-foot { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--ink-soft); font-size: .85rem; }
.site-foot p { margin: 0; max-width: 42rem; }

/* A frame size picker sits in the bar around it. */
.size-box { display: contents; }

/* The file-name option sits in the bar beside Save. */
.stamp-box { display: contents; }
.size-box label[hidden] { display: none; }
