/* D64 Disk Viewer: app-specific styles (shared styles: /assets/css/site.css) */

:root {
  --c64-blue: #40318d;       /* C64 screen */
  --c64-light: #7869c4;      /* C64 border and text */
  --stage: #000;
  --ok: #2ea043;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}
.app.loaded { grid-template-columns: minmax(0, 1fr) 340px; }
.app-head { grid-column: 1 / -1; max-width: 70ch; }
.app-head h1 { margin: 0 0 0.35rem; font-size: 2rem; color: var(--brand); }
.app-head p { margin: 0; color: var(--ink-soft); }

/* ---------- Drop zone ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 360px;
  padding: 2rem;
  text-align: center;
  background: var(--surface);
  border: 2px dashed #b9bccb;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--c64-light); background: #f3f1fd; }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone strong { font-size: 1.25rem; }
.dropzone span { color: var(--ink-soft); }
.dropzone .link-like { color: var(--link); text-decoration: underline; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone-disk { width: 120px; height: 120px; margin-bottom: 0.75rem; }
.dropzone-disk circle { fill: #2a2a2a; }
.dropzone-disk .track { fill: none; stroke: #3c8a4a; stroke-width: 5; stroke-dasharray: 9 2; }
.dropzone-disk .hole { fill: var(--surface); }
.dropzone.dragging .dropzone-disk .track { stroke: var(--c64-light); }

/* Drag over the whole page while a file is loaded */
body.dragging .canvas-wrap { outline: 3px dashed var(--c64-light); outline-offset: 4px; }

/* ---------- Preview ---------- */

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.file-name { font-weight: 700; overflow-wrap: anywhere; }

.canvas-wrap {
  position: relative;
  background: var(--stage);
  border-radius: var(--radius);
  padding: clamp(0.5rem, 2vw, 1.5rem);
  line-height: 0;
}
.canvas-wrap.transparent {
  background-color: #cfd1d6;
  background-image:
    linear-gradient(45deg, #b4b7bf 25%, transparent 25%, transparent 75%, #b4b7bf 75%),
    linear-gradient(45deg, #b4b7bf 25%, transparent 25%, transparent 75%, #b4b7bf 75%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
}
.canvas-wrap canvas { display: block; width: 100%; height: auto; cursor: crosshair; }
.busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  line-height: 1.5;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border-radius: var(--radius);
  font-weight: 700;
}
.busy[hidden] { display: none; }

.hover-info { min-height: 1.5em; margin: 0.6rem 0 0; color: var(--ink-soft); font-size: 0.9375rem; }

.error {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  background: #fdecea;
  border-left: 4px solid #c62828;
  border-radius: 4px;
  color: #7a1c1c;
}

/* ---------- Side panels ---------- */

.side { display: flex; flex-direction: column; gap: 1rem; }
.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.1rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.0625rem; color: var(--brand); }

.field { margin: 0 0 0.85rem; padding: 0; border: 0; }
.field > label, .field > legend { display: block; margin-bottom: 0.3rem; font-size: 0.875rem; font-weight: 700; padding: 0; }
.field select, .field input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #c5c8d4;
  border-radius: 5px;
}
.choice { display: inline-flex; align-items: center; gap: 0.4rem; margin-right: 1rem; font-size: 0.9375rem; cursor: pointer; }
.panel > .choice { display: flex; margin-bottom: 1rem; }

.btn {
  font: inherit;
  font-weight: 700;
  border-radius: 5px;
  cursor: pointer;
  padding: 0.6rem 1rem;
}
.btn-primary { width: 100%; color: #fff; background: var(--c64-blue); border: 0; }
.btn-primary:hover { background: #35287a; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-quiet { color: var(--brand); background: transparent; border: 1px solid var(--line); padding: 0.4rem 0.8rem; font-size: 0.9375rem; }
.btn-quiet:hover { border-color: var(--brand); }

.hint { margin: -0.25rem 0 0.75rem; font-size: 0.875rem; color: var(--ink-soft); }

/* Legend */
.legend { list-style: none; margin: 0; padding: 0; font-size: 0.9375rem; }
.legend li { display: flex; align-items: center; gap: 0.6rem; padding: 0.2rem 0; }
.legend .swatch {
  width: 1.4rem;
  height: 0.9rem;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--on) 0 3px, var(--off) 3px 5px);
}
.legend .count { margin-left: auto; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Disk facts */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; margin: 0; font-size: 0.9375rem; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Directory, drawn like a C64 screen ---------- */

.c64 {
  container-type: inline-size;
  background: var(--c64-blue);
  border: 14px solid var(--c64-light);
  padding: 0.6rem 0;
  max-height: 420px;
  overflow: auto;
  font-family: "Press Start 2P", monospace;
  color: var(--c64-light);
}
.c64-line, .c64-file {
  display: block;
  width: 100%;
  padding: 0.18em 0.6em;
  font: inherit;
  font-size: clamp(7px, 3.3cqi, 11px);
  line-height: 1.35;
  white-space: pre;
  text-align: left;
  color: inherit;
  background: none;
  border: 0;
}
.c64-file { cursor: pointer; }
.c64-file:hover { background: rgba(120, 105, 196, 0.25); }
.c64-file:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.c64-file[aria-pressed="true"] { background: var(--c64-light); color: var(--c64-blue); }
.c64 .reverse { background: var(--c64-light); color: var(--c64-blue); }
.c64-empty { opacity: 0.8; }

#clear-highlight { margin-top: 0.75rem; }

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .app.loaded { grid-template-columns: minmax(0, 1fr); }
  .app-head h1 { font-size: 1.6rem; }
  .dropzone { min-height: 260px; }
}
