/* style.css — squif
   Type: Space Mono, caps, 6pt with tracking 100 (= 0.1em).
   Grid taken from SQUIF-SITE-NEW.pdf: even 131pt columns, two rows at
   48.65% and 71.09% of the page height. Mapped to a 1440px window those
   become 224px columns, 10px type, and a 49px left margin. */

/* Space Mono, bundled locally (SIL Open Font License) so the page makes no
   third-party requests at all — nothing about a visit leaves the machine. */

@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/space-mono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/space-mono-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/space-mono-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/space-mono-700-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}


:root {
  --font-mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --ink: #000;
  --paper: #fff;

  --margin-x: 49px;
  --col: 224px;          /* 131pt column, mapped to a 1440px window */
  --row-top: 48.65%;
  --row-bottom: 71.09%;

  --size-body: 10px;
  --track: 0.1em;        /* InDesign tracking 100 */
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--size-body);
  font-weight: 400;
  letter-spacing: var(--track);
  text-transform: uppercase;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- The dropped GIF fills the window, dimmed, and the type flips to white --- */

#gif-background,
#overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#gif-background {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.45s ease;
}

#overlay {
  background: #000;
  opacity: 0;
  transition: opacity 0.45s ease;
}

body.has-gif #gif-background { opacity: 1; }
body.has-gif #overlay { opacity: 0.55; }
body.has-gif { color: #fff; }

body.drag-over #overlay { opacity: 0.68; }
body.drag-over:not(.has-gif) { background: #f2f2f2; }

/* --- Grid --- */

#app {
  position: relative;
  height: 100%;
}

/* The wordmark holds the first column on its own, in every state */
#logo {
  position: absolute;
  top: var(--row-top);
  left: var(--margin-x);
  margin: 0;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--size-body);
  letter-spacing: var(--track);
  line-height: 1;
}

.state { position: absolute; inset: 0; }

/* Each row starts at the second column and steps across in equal columns */
.row {
  position: absolute;
  left: calc(var(--margin-x) + var(--col));
  right: var(--margin-x);
  display: flex;
  align-items: flex-start;
}

.row-top { top: var(--row-top); transform: translateY(-50%); }
.row-bottom { top: var(--row-bottom); transform: translateY(-50%); }

.cell {
  flex: 0 0 var(--col);
  font-family: var(--font-mono);
  font-size: var(--size-body);
  letter-spacing: var(--track);
  line-height: 1.6;
}

.cell-wide { flex: 0 0 calc(var(--col) * 2); }

.as-text {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  font-family: var(--font-mono);
  font-size: var(--size-body);
  letter-spacing: var(--track);
  text-transform: inherit;
  text-align: left;
  cursor: pointer;
}

.as-text:hover { opacity: 0.55; }
.as-text:disabled { cursor: default; opacity: 1; }

/* Must come after .as-text — its `font: inherit` would otherwise reset the
   weight back to regular. */
.bold { font-weight: 700; }

/* --- Target size --- */

.size-field {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 var(--col);
}

/* The rule is drawn around the field and the unit, with a divider between */
.size-field > input,
.size-field > .size-unit {
  border: 1px solid currentColor;
}

#target-size-input {
  width: 86px;
  border-right: none;
  background: none;
  color: inherit;
  font-family: var(--font-mono);
  font-size: var(--size-body);
  letter-spacing: var(--track);
  text-align: left;
  padding: 0 6px;
  height: 18px;
  outline: none;
  -moz-appearance: textfield;
}

#target-size-input::-webkit-outer-spin-button,
#target-size-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.size-unit {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  height: 18px;
  font-family: var(--font-mono);
  font-size: var(--size-body);
  letter-spacing: var(--track);
}

/* --- Processing --- */

/* "squifing..." fades gently in and out as a whole word */
.pulse-word { animation: breathe 2.2s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.progress-cell { padding-top: 7px; }

/* A hairline rule with a thicker line growing across it, left to right */
.progress-track {
  position: relative;
  display: block;
  width: 180px;
  height: 3px;
}

.progress-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: currentColor;
  opacity: 0.4;
  transform: translateY(-50%);
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 50%;
  width: 0%;
  height: 3px;
  background: currentColor;
  transform: translateY(-50%);
  transition: width 0.35s ease;
}

/* --- Results --- */

/* Lists hang from the lower row line rather than centring on it, so a long
   one grows downward instead of creeping up into the row above. */
.row-list,
.results-row {
  align-items: flex-start;
  transform: translateY(-8px);   /* half a line, so row one sits on the line */
}

.results-row { display: block; }

.results,
.file-list {
  max-height: 24vh;
  overflow-y: auto;
}

.file-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 9px;
}

/* Filenames keep their real capitalisation — they're the user's data */
.file-name {
  flex: 0 0 var(--col);
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 16px;
}

.file-size { flex: 0 0 var(--col); white-space: nowrap; }
.file-reduction { white-space: nowrap; }

.file-row.failed .file-size,
.file-row.failed .file-reduction { opacity: 0.5; }

/* --- Narrow screens --- */
/* The three-column grid can't survive a phone, so the columns stack and
   the two rows collapse into one block. */

@media (max-width: 860px) {
  :root {
    --margin-x: 24px;
    --col: 150px;
  }

  #logo {
    top: 32%;
    transform: none;
  }

  .state { inset: 0; }

  .row {
    left: var(--margin-x);
    right: var(--margin-x);
    flex-wrap: wrap;
    gap: 14px 0;
  }

  .row-top { top: 40%; transform: none; }
  .row-bottom { top: 56%; transform: none; }

  .cell { flex: 0 0 100%; }
  .cell-wide { flex: 0 0 100%; }

  .size-field { flex: 0 0 100%; }

  .file-row { flex-wrap: wrap; gap: 2px 0; }
  .file-name, .file-size { flex: 0 0 100%; }

  .results { max-height: 34vh; }
}
