/* Applet styles (projects, terminal, tools). Loaded with the first applet window that opens. */
/* ---------- project cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px; padding: 6px; }
.card { padding: 22px; position: relative; transition: transform .15s steps(3); }
@media (hover: hover) {
  .card:hover { --c: var(--or); transform: translate(-4px, -4px); box-shadow: 0 -4px 0 0 var(--c), 0 4px 0 0 var(--c), -4px 0 0 0 var(--c), 4px 0 0 0 var(--c), 12px 12px 0 0 var(--bl); }
}
.ident { width: 64px; height: 64px; image-rendering: pixelated; display: block; }
.card h3 { font-size: 13px; color: var(--or); margin: 18px 0 10px; }
.card p { margin: 0 0 12px; color: #c9c7d1; }
.tags { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li { font-size: 18px; color: var(--bl); border: 2px solid var(--bl-lo); padding: 0 8px; }
.links { display: flex; gap: 18px; }
.links a { font: 10px var(--pixel); text-decoration: none; }

.pico { width: 96px; height: 96px; display: block; image-rendering: auto; border: 4px solid var(--line); background: #000; }
.card:hover .pico { border-color: var(--bl); }
/* The whole project card opens its write-up: the READ link's click area is stretched over the card, so
   keyboard focus, middle-click and "open in new tab" all still work like the link itself. */
.proj .read::after { content: ""; position: absolute; inset: 0; }
.proj:has(.read:focus-visible) { --c: var(--or); }
.status { font: 8px/1.6 var(--pixel); color: #3bff8a; margin: 0 0 12px !important; display: flex; align-items: center; gap: 8px; }
.status::before { content: ""; width: 8px; height: 8px; flex: none; background: currentColor; box-shadow: 0 0 8px currentColor; animation: blink 1.6s steps(2) infinite; }

/* "more soon" card: cobweb + dangling spider */
.card.more { position: relative; min-height: 260px; display: grid; place-content: center; text-align: center; overflow: hidden;
  border: 4px dashed var(--line); background: transparent; }
.card.more h3 { position: relative; margin-top: 0; color: var(--dim); }
.card.more p { position: relative; margin: 0 auto; max-width: 26ch; }
.web { position: absolute; top: 0; left: 0; width: min(200px, 40%); fill: none; stroke: var(--dim); stroke-width: .5; opacity: .7; pointer-events: none; }
.web.br { top: auto; left: auto; bottom: 0; right: 0; transform: rotate(180deg); width: min(140px, 30%); }
.spider { position: absolute; top: 0; right: 28%; width: 2px; height: 70px; background: var(--dim); transform-origin: top; animation: dangle 3s steps(6) infinite alternate; }
.spider i { position: absolute; top: 100%; left: -1px; width: 3px; height: 3px; box-shadow: -12px 0 var(--dim), 12px 0 var(--dim), -9px 3px var(--dim), -3px 3px var(--or), 0 3px var(--or), 3px 3px var(--or), 9px 3px var(--dim), -12px 6px var(--dim), -9px 6px var(--dim), -3px 6px var(--or), 0 6px var(--or), 3px 6px var(--or), 9px 6px var(--dim), 12px 6px var(--dim), -6px 9px var(--dim), -3px 9px var(--or), 0 9px var(--or), 3px 9px var(--or), 6px 9px var(--dim), -9px 12px var(--dim), -3px 12px var(--or), 3px 12px var(--or), 9px 12px var(--dim), -12px 15px var(--dim), 12px 15px var(--dim); }
@keyframes dangle { to { height: 110px; } }

/* ---------- project article (/projects/<name>/) ---------- */
.art { counter-reset: sec; }
.art > p, .art .note p { max-width: 74ch; color: #c9c7d1; }
.back { display: inline-block; font: 10px var(--pixel); text-decoration: none; margin-bottom: 14px; }
.hero { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 22px; padding: 22px; margin-bottom: 8px; overflow: hidden;
  border: 4px solid var(--line);
  background:
    linear-gradient(115deg, transparent 38%, #ff7a1822 44%, transparent 52%),
    linear-gradient(115deg, transparent 56%, #2ea8ff1c 60%, transparent 66%),
    linear-gradient(115deg, transparent 70%, #ffffff0d 72%, transparent 75%),
    #05050a; }
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, #0000004d 2px 4px); }
.hero > * { position: relative; z-index: 1; }
.hero-ico { width: 128px; height: 128px; flex: none; border: 4px solid var(--or); box-shadow: 8px 8px 0 var(--bl-lo); }
.hero h2 { font-size: 20px; line-height: 1.4; color: var(--or); margin: 0 0 12px; text-shadow: 4px 4px 0 var(--or-lo); }
.hero .tags { margin-bottom: 16px; }
.hero p:last-child { margin: 0; }
.art h3 { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--or); margin: 36px 0 14px; counter-increment: sec; }
.art h3::before { content: counter(sec, decimal-leading-zero); color: var(--bl); font-size: 10px; }
.art h3::after { content: ""; flex: 1; height: 4px; min-width: 24px;
  background: repeating-linear-gradient(90deg, var(--or) 0 4px, transparent 4px 8px);
  -webkit-mask: linear-gradient(90deg, #000, transparent); mask: linear-gradient(90deg, #000, transparent); }
.pull { font-size: 26px; color: var(--or-hi) !important; border-left: 4px solid var(--or); padding-left: 16px; }
.feats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; padding: 4px; }
.feat { padding: 16px 18px; }
.feat h4 { font-size: 10px; line-height: 1.6; color: var(--or); margin: 0 0 10px; }
.feat h4::before { content: "\25B6  "; color: var(--bl); }
.feat p { margin: 0 0 10px; color: #c9c7d1; }
.feat p:last-child { margin: 0; }
.badge { display: inline-block; font-size: 7px; color: #000; background: #ff3b5c; padding: 3px 5px; vertical-align: 2px; margin-left: 4px; }
.rig { display: grid; grid-template-columns: auto 1fr; gap: 4px 18px; max-width: 520px; margin: 16px 0; padding: 14px 18px;
  background: #000; border-left: 4px solid var(--bl); font-size: 20px; }
.rig dt { color: var(--dim); }
.rig dt.hd { grid-column: 1 / -1; font: 10px var(--pixel); color: var(--bl); margin-bottom: 6px; }
.rig dd { margin: 0; }
.note { margin: 18px 0; padding: 12px 18px; border: 4px dashed var(--or-lo); background: #ff7a180a; }
.note b { font: 10px var(--pixel); font-weight: normal; color: var(--or); }
.note p { margin: 8px 0 0; }
.gallery { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
@container (min-width: 640px) { .gallery { grid-template-columns: 1fr 1fr; } }
.gallery figure { margin: 0; border: 4px solid var(--line); background: #000; transition: transform .15s steps(3), border-color .15s steps(3); }
.gallery figure:hover { border-color: var(--or); transform: translate(-4px, -4px); box-shadow: 8px 8px 0 var(--bl-lo); }
.gallery a { display: block; }
.gallery img { display: block; width: 100%; height: auto; }
.gallery figcaption { padding: 8px 12px; color: var(--text); }
.gallery figcaption b { font: 8px var(--pixel); font-weight: normal; color: var(--or); margin-right: 10px; }
@media (prefers-reduced-motion: reduce) {
  .status::before { animation: none; }
  .gallery figure { transition: none; }
}

/* ---------- tools ---------- */
.tool { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px; }
.wb h4 { font-size: 10px; color: var(--or); margin: 22px 0 8px; }
.wb h4 small { font: 16px var(--mono); color: var(--dim); }
.lbl { display: block; font: 10px var(--pixel); color: var(--or); margin: 14px 0 8px; }
.lbl b { color: var(--bl); font-weight: normal; }
textarea, input[type="text"], select {
  width: 100%; background: #000; color: var(--text); font: 22px var(--mono);
  border: 4px solid var(--line); padding: 8px; resize: vertical;
}
select { width: auto; padding: 4px 8px; }
textarea:focus, input[type="text"]:focus, select:focus { border-color: var(--or); outline: none; }
input[type="range"] { width: 100%; accent-color: var(--or); }
input[type="checkbox"] { accent-color: var(--or); width: 18px; height: 18px; vertical-align: -3px; }
input[type="color"] { width: 56px; height: 48px; border: 4px solid var(--line); background: #000; padding: 0; }
.color-in { display: inline-flex; align-items: center; gap: 8px; font: 10px var(--pixel); margin-right: 8px; }
.color-in input { width: 40px; height: 36px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 12px; }

/* stats panel */
.stats { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-content: start; font-size: 20px; border-left: 4px dashed var(--line); padding-left: 20px; }
.stats dt { color: var(--dim); }
.stats dd { margin: 0; color: var(--text); word-break: break-word; text-align: right; }
.stats dd.or { color: var(--or); }
.stats dd.bl { color: var(--bl); }
.stats dd.bad { color: #ff3b5c; }
.stats dd.good { color: #3bff8a; }
.stats dt.hd { grid-column: 1 / -1; font: 10px var(--pixel); color: var(--or); margin-top: 12px; }
.meter { display: block; position: relative; text-align: right; padding-bottom: 6px; }
.meter::after { content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: var(--p); background: repeating-linear-gradient(90deg, var(--or) 0 4px, transparent 4px 6px); }
.sw { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff3; vertical-align: -1px; margin-right: 6px; }

/* pixel canvas */
.pc-wrap {
  --n: 32; position: relative; width: 100%; max-width: 512px; aspect-ratio: 1; border: 4px solid var(--line);
  background-color: #0d0d14;
  background-image:
    linear-gradient(90deg, #ffffff10 1px, transparent 1px),
    linear-gradient(#ffffff10 1px, transparent 1px);
  background-size: calc(100% / var(--n)) calc(100% / var(--n));
}
#pc { width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: none; cursor: crosshair; }
#pal button { width: 28px; height: 28px; border: 2px solid #000; margin: 0; padding: 0; box-shadow: 0 0 0 2px var(--line); }
#pal button.on { box-shadow: 0 0 0 3px var(--or); transform: translateY(-2px); }

/* encode outputs */
.outs { display: grid; gap: 6px; }
.out { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; align-items: center; gap: 10px; background: #000; padding: 4px 4px 4px 10px; border-left: 4px solid var(--bl-lo); }
.out b { font: 8px var(--pixel); color: var(--dim); font-weight: normal; }
.out code { font: 18px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.out code.err { color: var(--dim); }
.out .btn { margin: 0; padding: 6px 8px; font-size: 8px; }

/* color */
.swatch { display: flex; justify-content: space-between; align-items: end; height: 140px; padding: 14px; margin-top: 10px; border: 4px solid #000; box-shadow: 0 0 0 4px var(--line); font-size: 26px; }
.swatch .inv { color: #fff; }
.swatch span:first-child { color: #000; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { font: 16px var(--mono); color: #fff; margin: 0; display: grid; place-items: end start; width: 74px; height: 50px; padding: 3px; font-size: 14px; border: 2px solid #000; box-shadow: 0 0 0 2px var(--line); }
.chips button:hover { box-shadow: 0 0 0 2px var(--or); }
.chips button i { font-style: normal; background: #000c; padding: 0 3px; }

/* password */
.pw { display: block; background: #000; border: 4px solid var(--or-lo); padding: 14px; font-size: 26px; color: var(--or-hi); word-break: break-all; min-height: 64px; }

/* system */
.sys { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 24px; }
.sys .stats { border-left-color: var(--bl-lo); }
.sys h4 { margin: 0 0 6px; }

#toast {
  position: fixed; left: 50%; bottom: 64px; transform: translate(-50%, 300%); z-index: 100002; visibility: hidden;
  font: 11px var(--pixel); background: var(--or); color: #000; padding: 14px 18px;
  box-shadow: 0 -4px 0 0 #000, 0 4px 0 0 #000, -4px 0 0 0 #000, 4px 0 0 0 #000, 8px 8px 0 0 var(--bl);
  transition: transform .25s steps(4), visibility .25s;
}
#toast.on { transform: translate(-50%, 0); visibility: visible; }

@container (max-width: 640px) {
  .tool { grid-template-columns: 1fr; }
  .stats { border-left: 0; padding-left: 0; border-top: 4px dashed var(--line); padding-top: 16px; }
}

/* terminal */
.term { background: #000; font-size: 20px; cursor: text; }
#termOut div { white-space: pre-wrap; word-break: break-word; }
#termOut .cmd { color: var(--dim); }
#termOut .or { color: var(--or); }
#termOut .bl { color: var(--bl); }
#termForm { display: flex; gap: 8px; }
#termForm label { color: var(--or); white-space: nowrap; }
#termIn { flex: 1; min-width: 0; background: none; border: 0; padding: 0; color: var(--text); font: inherit; caret-color: var(--or); }
#termIn:focus { outline: none; }

/* ---------- image viewer (projects.js): full size, nothing drawn on top ---------- */
dialog.viewer { padding: 0; border: 4px solid var(--line); background: #000; color: var(--text); max-width: 100vw; max-height: 100vh;
  width: max-content; overflow: hidden; display: none; }
dialog.viewer[open] { display: flex; flex-direction: column; }
dialog.viewer::backdrop { background: #000e; }
.v-bar { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 12px; border-bottom: 4px solid var(--line); }
.v-cap { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-orig { font: 8px var(--pixel); color: var(--bl); white-space: nowrap; }
.v-x { font: 12px var(--pixel); color: #000; background: var(--or); border: 0; min-width: 40px; min-height: 40px; cursor: pointer; }
.v-img { overflow: auto; max-height: calc(100vh - 64px); max-width: calc(100vw - 8px); }
.v-img img { display: block; margin: auto; max-width: none; }
.gallery a:has(img) { cursor: zoom-in; }
