/* Screenprint / halftone — black ink on green paper */

:root {
  /* Light paper tint based on #5F7738 */
  --paper: #e7eddc;
  --paper-bright: #f5f8ef;
  --ink: #0a0a0a;
  --ink-soft: #2a2a2a;
  --muted: #3f4b32;
  --line: #0a0a0a;
  --accent: #0a0a0a;
  --halftone-dot: rgba(95, 119, 56, 0.09);
  --paper-deep: #d2dcc3;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  /* Halftone screen around the page */
  background-image:
    radial-gradient(circle at 1px 1px, var(--halftone-dot) 0.65px, transparent 0.7px),
    linear-gradient(180deg, var(--paper-bright) 0%, var(--paper) 45%, var(--paper-deep) 100%);
  background-size: 6px 6px, 100% 100%;
  background-attachment: fixed;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  width: 100%;
  box-sizing: border-box;
}

.print-frame {
  position: relative;
}

/* Thick ink border frame */
.print-frame::before {
  content: "";
  position: fixed;
  inset: 12px;
  border: 3px solid var(--ink);
  pointer-events: none;
  z-index: 0;
  box-shadow: inset 0 0 0 1px var(--paper-bright);
}

@media (max-width: 600px) {
  .print-frame::before {
    inset: 8px;
    border-width: 2px;
  }
}

.topbar-brand {
  flex: 1 1 auto;
  min-width: 0;
}

.brand-gallery-link-wrap {
  margin: 8px 0 0;
}

.brand-gallery-link {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.brand-gallery-link:hover {
  color: var(--ink-soft);
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px;
  background: var(--paper-bright);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
}

.actions--header {
  flex: 0 0 auto;
  margin-left: auto;
  justify-content: flex-end;
}

.h1 {
  font-family: "Archivo Black", Impact, sans-serif;
  font-size: clamp(1.5rem, 4vw, 1.85rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.1;
  color: var(--ink);
}

.sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.actions button,
.file span {
  height: 40px;
  padding: 0 16px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper-bright);
  box-shadow: 4px 4px 0 rgba(10, 10, 10, 0.25);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease, color 0.12s ease;
}

.actions button:hover,
.file span:hover {
  background: var(--paper-bright);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
}

.actions button:active,
.file span:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.file input {
  display: none;
}

.file span {
  display: inline-flex;
  align-items: center;
}

.content {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr min(360px, 100%);
  gap: 20px;
}

@media (max-width: 980px) {
  .content {
    grid-template-columns: 1fr;
  }
}

/* Shrink-wrap preview to actual canvas (image + margin), centered in column */
.canvasCol {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  width: 100%;
}

.canvasWrap {
  position: sticky;
  top: 18px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  line-height: 0;
}

/* On mobile/single-column layouts, don't sticky-pin the preview. */
@media (max-width: 980px) {
  .canvasWrap {
    position: relative;
    top: auto;
  }
}

/* Registration marks (print shop corners) */
.reg {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--ink);
  border-style: solid;
  z-index: 2;
  pointer-events: none;
}
.reg-tl {
  top: 10px;
  left: 10px;
  border-width: 2px 0 0 2px;
}
.reg-tr {
  top: 10px;
  right: 10px;
  border-width: 2px 2px 0 0;
}
.reg-bl {
  bottom: 10px;
  left: 10px;
  border-width: 0 0 2px 2px;
}
.reg-br {
  bottom: 10px;
  right: 10px;
  border-width: 0 2px 2px 0;
}

#canvasMount {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.04) 0.5px, transparent 0.55px);
  background-size: 5px 5px;
}

#canvasMount canvas {
  display: block;
  /* Visual scale only: backing store stays full res; PNG export is still native pixels. */
  max-width: min(100%, 94vw);
  max-height: min(88vh, 92vw);
  width: auto;
  height: auto;
  object-fit: contain;
  vertical-align: top;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.status {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 3;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  background: rgba(240, 248, 242, 0.94);
  border: 2px solid var(--ink);
  padding: 8px 10px;
  max-width: min(92%, 420px);
  line-height: 1.35;
}

.panel {
  background: var(--paper-bright);
  border: 3px solid var(--ink);
  padding: 18px 16px 20px;
  box-shadow: 6px 6px 0 var(--ink);
}

.panelTitle {
  font-family: "Archivo Black", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--ink);
  color: var(--ink);
}

.panelTitleMark {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 8px;
  background: var(--ink);
  color: var(--paper-bright);
  font-size: 0.72rem;
  vertical-align: middle;
  letter-spacing: 0.1em;
}

hr {
  border: none;
  border-top: 2px dashed var(--ink);
  margin: 14px 0;
  opacity: 0.35;
}

.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 12px 0;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.num {
  box-sizing: border-box;
  align-self: flex-start;
  min-width: 7.5ch;
  width: auto;
  max-width: min(100%, 26ch);
  padding: 4px 7px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  line-height: 1.2;
  color: var(--ink);
  background:#fff;
  border:2px solid var(--ink);
  border-radius:0;
}
.num:focus{
  outline:none;
  box-shadow: inset 0 0 0 1px var(--ink);
}

.row label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

select {
  width: 100%;
  padding: 10px 12px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%230a0a0a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

select:hover,
select:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--ink);
}

/* Range — ink on track */
input[type="range"] {
  width: 100%;
  height: 8px;
  appearance: none;
  background: transparent;
  margin: 4px 0 2px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  background: linear-gradient(90deg, #fff 0%, #c5d4c8 100%);
  border: 2px solid var(--ink);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 0;
  box-shadow: 2px 2px 0 rgba(10, 10, 10, 0.2);
  cursor: grab;
}

input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
}

input[type="range"]::-moz-range-track {
  height: 6px;
  background: #c5d4c8;
  border: 2px solid var(--ink);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 0;
  cursor: grab;
}

.hint {
  margin-top: 14px;
  padding: 12px;
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--muted);
  border: 2px dashed rgba(10, 10, 10, 0.35);
  background: rgba(255, 255, 255, 0.5);
}

.hint strong {
  color: var(--ink);
  font-weight: 600;
}

/* Top bar — link to gallery */
.gallery-nav {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  border: 2px solid var(--ink);
  background: var(--paper-bright);
  box-shadow: 4px 4px 0 rgba(10, 10, 10, 0.2);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.12s ease;
}

.gallery-nav:hover {
  background: var(--ink);
  color: var(--paper-bright);
}

.gallery-nav:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(10, 10, 10, 0.25);
}

/* Image archive */
.gallery-section {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 36px auto 0;
  padding: 0 20px 48px;
  scroll-margin-top: 24px;
}

.gallery-heading {
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 8px;
  color: var(--ink);
}

.gallery-lede {
  margin: 0 0 20px;
  max-width: 52ch;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.gallery-item {
  margin: 0;
  padding: 0;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gallery-item--yours {
  border-style: dashed;
}

.gallery-thumb {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: #fff;
  cursor: pointer;
  line-height: 0;
  font: inherit;
  color: inherit;
}

.gallery-thumb:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

.gallery-thumb img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.gallery-item figcaption {
  padding: 8px 10px 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.62rem;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  border-top: 2px solid rgba(10, 10, 10, 0.12);
  word-break: break-word;
}

.gallery-back {
  margin: 24px 0 0;
  font-size: 0.78rem;
}

.gallery-back a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.gallery-back a:hover {
  text-decoration-thickness: 2px;
}

/* Lightbox slideshow */
body.gallery-lightbox-open {
  overflow: hidden;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  padding: 0;
  margin: 0;
}

.gallery-lightbox[hidden] {
  display: none;
}

.gallery-lightbox-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}

.gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.85);
  border: none;
  cursor: pointer;
  padding: 0;
}

.gallery-lightbox-panel {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1100px);
  max-height: 94vh;
  width: 100%;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 12px 12px 0 rgba(10, 10, 10, 0.35);
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.gallery-lightbox-close {
  align-self: flex-end;
  margin-bottom: 6px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper-bright);
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(10, 10, 10, 0.2);
}

.gallery-lightbox-close:hover {
  background: var(--paper-bright);
  color: var(--ink);
}

.gallery-lightbox-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: 0;
}

.gallery-lightbox-arrow {
  flex-shrink: 0;
  width: 44px;
  height: 48px;
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--paper-bright);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(10, 10, 10, 0.15);
}

.gallery-lightbox-arrow:hover {
  background: var(--ink);
  color: var(--paper-bright);
}

.gallery-lightbox-stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.gallery-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: min(76vh, 88vw);
  width: auto;
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.gallery-lightbox-caption {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: 0;
  text-align: center;
  max-width: 100%;
  line-height: 1.35;
}

.gallery-lightbox-counter {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.65rem;
  color: var(--muted);
  margin: 0;
}

@media (max-width: 520px) {
  .gallery-lightbox-body {
    flex-wrap: wrap;
    justify-content: center;
  }

  .gallery-lightbox-stage {
    order: -1;
    flex: 1 1 100%;
  }

  .gallery-lightbox-arrow {
    width: 48%;
    max-width: 160px;
  }
}

/* ——— Mobile layout ——— */
@media (max-width: 640px) {
  .app {
    padding: 16px 12px 28px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 14px 16px;
  }

  .actions--header {
    margin-left: 0;
    width: 100%;
  }

  .actions {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }

  .actions > .file,
  .actions > button {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .actions button,
  .file span {
    min-height: 44px;
    padding: 0 12px;
    font-size: 0.7rem;
  }

  .file span {
    width: 100%;
    justify-content: center;
  }

  .content {
    margin-top: 16px;
    gap: 16px;
  }

  .canvasWrap {
    box-shadow: 6px 6px 0 var(--ink);
  }

  #canvasMount canvas {
    max-width: 100%;
    max-height: min(72vh, 100vw);
  }

  .status {
    left: 8px;
    right: 8px;
    bottom: 10px;
    max-width: none;
    font-size: 10px;
    padding: 6px 8px;
  }

  .panel {
    padding: 14px 12px 16px;
  }

  .panelTitle {
    font-size: 0.88rem;
    margin-bottom: 12px;
  }

  .gallery-section {
    margin-top: 24px;
    padding: 0 0 36px;
  }

  .gallery-lede {
    max-width: none;
    font-size: 0.76rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 112px), 1fr));
    gap: 10px;
  }

  .gallery-item figcaption {
    font-size: 0.58rem;
    padding: 6px 8px 8px;
  }
}

@media (max-width: 380px) {
  .actions {
    flex-direction: column;
  }

  .actions > .file {
    width: 100%;
  }

  .actions > .file,
  .actions > button {
    flex: 1 1 auto;
    width: 100%;
  }
}
