/* Filekin
   Palette: cool paper, slate ink, pine for actions, and highlighter yellow
   used in exactly one place: the drop zone. */

:root {
  --paper: #F5F7F4;
  --surface: #FFFFFF;
  --ink: #18232E;
  --muted: #56636E;
  --line: #D3DAD4;
  --pine: #0F6A57;
  --pine-ink: #FFFFFF;
  --pine-soft: #E3EFEA;
  --highlight: #F3DA4E;
  --error: #B3261E;
  --error-soft: #FBEAE8;

  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;

  --radius-sheet: 14px;
  --radius-control: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121A20;
    --surface: #1A242C;
    --ink: #E7ECE8;
    --muted: #9AA7AE;
    --line: #2C3942;
    --pine: #3FB497;
    --pine-ink: #0B1915;
    --pine-soft: #17302A;
    --highlight: #E8CD3C;
    --error: #FF8A80;
    --error-soft: #3A1E1C;
    color-scheme: dark;
  }
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pine); }
a:focus-visible, button:focus-visible, .sheet:focus-visible {
  outline: 3px solid var(--pine);
  outline-offset: 3px;
}

h1, h2 { font-family: var(--display); font-weight: 700; margin: 0; }

/* ---------------------------------------------------------------- header */

.site-header {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font: 700 1.5rem/1 var(--display);
  letter-spacing: -.02em;
  color: var(--ink);
  text-decoration: none;
}

/* ---------------------------------------------------------------- home */

.home {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.hero {
  padding: clamp(3rem, 9vw, 6.5rem) 0 clamp(2.5rem, 6vw, 4rem);
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.6rem, 7.5vw, 5.25rem);
  line-height: .98;
  letter-spacing: -.035em;
}
/* Each half of the headline is its own line on screens wide enough to hold it. */
.hero h1 .line { display: block; }
@media (max-width: 40rem) { .hero h1 .line { display: inline; } }

.hero .lede { margin-inline: auto; }
.hero .promises { justify-content: center; }

.lede {
  color: var(--muted);
  font-size: 1.2rem;
  max-width: 34rem;
  margin: 1.25rem 0 0;
}

.promises {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  list-style: none;
  padding: 0;
  margin: 1.75rem 0 0;
  font-weight: 700;
}
.promises li::before {
  content: "";
  display: inline-block;
  width: .55em;
  height: .55em;
  margin-right: .5em;
  border-radius: 50%;
  background: var(--pine);
  vertical-align: .08em;
}

/* Tools on the left; Coming soon (and an ad, when ads are on) in a column on the
   right, the same width as the sidebar on tool pages. Stacks on narrow screens. */
.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: 3rem;
  align-items: start;
}
.home-aside {
  display: grid;
  gap: 2rem;
  border-top: 2px solid var(--ink);
  padding-top: 1.75rem;
}
@media (max-width: 56rem) {
  .home-layout { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- tool index
   A plain grouped list, like a well-kept filing index. */

.tool-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 2.5rem 2rem;
  border-top: 2px solid var(--ink);
  padding-top: 1.75rem;
}

.tool-group h2 {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .5rem;
}

.tool-group ul { list-style: none; margin: 0; padding: 0; }

/* Each tool is a button-like tile: a border, a hover lift and an arrow, so it
   reads as something to click rather than a line of text. */
.tool-group li + li { margin-top: .6rem; }

.tool-group a {
  position: relative;
  display: block;
  padding: .85rem 2.75rem .85rem 1rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.tool-group a::after {
  content: "";
  position: absolute;
  right: 1.1rem;
  top: 50%;
  width: .55rem;
  height: .55rem;
  border-top: 2.5px solid var(--muted);
  border-right: 2.5px solid var(--muted);
  transform: translateY(-50%) rotate(45deg);
  transition: border-color .15s ease, right .15s ease;
}
.tool-group a:hover {
  border-color: var(--pine);
  box-shadow: 0 2px 0 var(--pine);
  transform: translateY(-1px);
}
.tool-group a:hover::after { border-color: var(--pine); right: .9rem; }
.tool-group a:hover .tool-name { color: var(--pine); }

.tool-group a[aria-current="page"] {
  border-color: var(--pine);
  background: var(--pine-soft);
}
.tool-group a[aria-current="page"] .tool-name { color: var(--pine); }

.tool-name {
  display: block;
  font: 700 1.2rem/1.25 var(--display);
  letter-spacing: -.01em;
}
.tool-summary { display: block; color: var(--muted); font-size: .92rem; line-height: 1.45; margin-top: .2rem; }

/* Coming-soon tools are not clickable, so they stay plain and quiet. */
.soon li {
  padding: .45rem 0;
  border-bottom: 1px dashed var(--line);
  color: var(--muted);
}
.soon li + li { margin-top: 0; }

/* "Show all tools": the rest of the tools, folded away so the home page stays
   short. It spans the whole width and lays its own groups out in the same grid. */
.all-tools { grid-column: 1 / -1; }
.all-tools > summary {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  list-style: none;
  padding: .7rem 1.2rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  font: 700 1.05rem/1.2 var(--display);
  color: var(--ink);
  background: var(--surface);
}
.all-tools > summary::-webkit-details-marker { display: none; }
.all-tools > summary::after {
  content: "";
  width: .5rem;
  height: .5rem;
  border-right: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s ease;
}
.all-tools[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.all-tools > summary:hover { border-color: var(--pine); color: var(--pine); }
.all-tools > summary:focus-visible { outline: 3px solid var(--pine); outline-offset: 3px; }
.more-count {
  font: 400 .85rem/1 var(--body);
  color: var(--muted);
  padding: .25rem .55rem;
  background: var(--pine-soft);
  border-radius: 999px;
}
.all-tools-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 2.5rem 2rem;
  margin-top: 2rem;
}

.all-tools-link {
  font-weight: 700;
  color: var(--pine);
  text-underline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .all-tools > summary::after { transition: none; }
  .tool-group a, .tool-group a::after { transition: none; }
  .tool-group a:hover { transform: none; }
}

/* ---------------------------------------------------------------- tool page */

.tool-layout {
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 1.25rem 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: 4rem;
  align-items: start;
}

.workspace { max-width: 42rem; }

.workspace h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -.03em;
}

.sidebar {
  grid-template-columns: 1fr;
  gap: 1.75rem;
  border-top-width: 2px;
}
.sidebar .tool-summary { display: none; }
.sidebar .tool-name { font-size: 1.05rem; }
.sidebar .tool-group a { padding: .6rem 2.25rem .6rem .85rem; }
.sidebar .tool-group li + li { margin-top: .45rem; }

/* The drop zone is a sheet of paper. Its instruction is highlighted like a
   marked-up page, and the highlight sweeps across when a file hovers over it. */

.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .35rem;
  margin-top: 2rem;
  padding: 2.75rem 2rem 2rem;
  min-height: 15rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sheet);
  cursor: pointer;
}
/* Folded corner */
.sheet::after {
  content: "";
  position: absolute;
  top: -1.5px;
  right: -1.5px;
  width: calc(2.25rem + 1.5px);
  height: calc(2.25rem + 1.5px);
  background: linear-gradient(225deg, var(--paper) 50%, var(--line) 50%);
  border-bottom-left-radius: 5px;
}

.sheet-title {
  font: 700 clamp(1.6rem, 4vw, 2.1rem)/1.2 var(--display);
  letter-spacing: -.02em;
}
.sheet-title mark {
  color: inherit;
  background:
    linear-gradient(var(--highlight), var(--highlight))
    no-repeat 0 85% / 100% 55%;
  padding: 0 .15em;
  margin: 0 -.15em;
  transition: background-size .35s ease;
}
.sheet-sub { font-size: 1.1rem; }
.sheet-sub u { text-decoration-color: var(--pine); text-underline-offset: .2em; }
.sheet-meta { margin-top: auto; padding-top: 1.5rem; color: var(--muted); font-size: .9rem; }

.sheet.dragging { border-color: var(--pine); border-style: dashed; }
.sheet.dragging .sheet-title mark { background-size: 100% 95%; }

.sheet.compact { min-height: 0; padding: 1.1rem 1.5rem; flex-direction: row; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.sheet.compact .sheet-title { font-size: 1.15rem; }
.sheet.compact .sheet-meta { margin: 0; padding: 0; }
.sheet.compact::after { width: calc(1.25rem + 1.5px); height: calc(1.25rem + 1.5px); }

@media (prefers-reduced-motion: reduce) {
  .sheet-title mark { transition: none; }
}

/* ---------------------------------------------------------------- file list */

.file-list {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  counter-reset: file;
}

.file-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .75rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--line);
  counter-increment: file;
}
/* Numbers only appear when order matters (merge). */
.file-list.ordered li::before {
  content: counter(file);
  font: 700 1rem/1 var(--display);
  color: var(--muted);
  min-width: 1.5ch;
  text-align: right;
}
.file-list:not(.ordered) li { grid-template-columns: minmax(0, 1fr) auto; }

.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.file-size { color: var(--muted); font-weight: 400; margin-left: .5rem; }

.file-actions { display: flex; gap: .25rem; }
.icon-button {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  cursor: pointer;
}
.icon-button:hover:not(:disabled) { border-color: var(--ink); }
.icon-button:disabled { opacity: .35; cursor: default; }

/* ---------------------------------------------------------------- options */

.options:empty { display: none; }
.options { margin-top: 1.75rem; display: grid; gap: 1.5rem; }

fieldset { border: 0; margin: 0; padding: 0; }
legend, .field-label {
  display: block;
  font: 700 1.05rem/1.3 var(--display);
  margin-bottom: .6rem;
  padding: 0;
}

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .6rem; }

.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: block;
  height: 100%;
  padding: .75rem .9rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.choice strong { display: block; }
.choice small { display: block; color: var(--muted); font-size: .88rem; line-height: 1.35; margin-top: .15rem; }
.choice input:checked + span { border-color: var(--pine); background: var(--pine-soft); box-shadow: inset 0 0 0 1px var(--pine); }
.choice input:focus-visible + span { outline: 3px solid var(--pine); outline-offset: 2px; }

.text-input {
  width: 100%;
  max-width: 24rem;
  font: inherit;
  padding: .65rem .8rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}
.text-input:focus { outline: 3px solid var(--pine); outline-offset: 1px; border-color: var(--pine); }
.field-help { color: var(--muted); font-size: .9rem; margin: .4rem 0 0; }

/* ---------------------------------------------------------------- actions */

.actions { margin-top: 2rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: 0 1.75rem;
  border-radius: var(--radius-control);
  font: 700 1.1rem/1 var(--body);
  text-decoration: none;
  cursor: pointer;
}
.primary { background: var(--pine); color: var(--pine-ink); border: 0; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary:disabled { opacity: .4; cursor: default; }
.secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.secondary:hover { border-color: var(--ink); }

.status { margin: 0; color: var(--muted); }
.status.error {
  color: var(--error);
  background: var(--error-soft);
  padding: .6rem .85rem;
  border-radius: var(--radius-control);
  flex-basis: 100%;
}

.busy .primary { position: relative; color: transparent; }
.busy .primary::after {
  content: "";
  position: absolute;
  width: 1.2rem;
  height: 1.2rem;
  border: 2.5px solid var(--pine-ink);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- result */

.result {
  margin-top: 2rem;
  padding: 1.5rem 1.75rem;
  border-left: 4px solid var(--pine);
  background: var(--pine-soft);
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
}
.result-title { font: 700 1.5rem/1.2 var(--display); margin: 0; }
.result-detail { margin: .35rem 0 0; color: var(--muted); }
.result-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* ---------------------------------------------------------------- footer */

.site-footer {
  max-width: 72rem;
  margin: 5rem auto 0;
  padding: 1.5rem 1.25rem 2.5rem;
  color: var(--muted);
  font-size: .92rem;
}
.site-footer p { max-width: 40rem; margin: 0; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 52rem) {
  .tool-layout { grid-template-columns: 1fr; gap: 3rem; }
  .sheet { padding: 2rem 1.25rem 1.5rem; min-height: 12rem; }
}

/* In dark mode the highlighter covers the whole line, so the dark text on it stays readable. */
@media (prefers-color-scheme: dark) {
  .sheet-title mark { color: #18232E; background-size: 100% 100%; }
}

/* ---------------------------------------------------------------- legal + contact pages */

.prose-page {
  max-width: 42rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4rem) 1.25rem 0;
}
.prose-page h1 {
  font-size: clamp(2.2rem, 5.5vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -.03em;
}
.prose-page h2 { font-size: 1.35rem; margin: 2.25rem 0 .5rem; letter-spacing: -.01em; }
.prose-page p, .prose-page li { max-width: 38rem; }
.prose-page ul { padding-left: 1.25rem; }
.prose-page li { margin-bottom: .6rem; }
.updated { color: var(--muted); margin-top: .5rem; }

/* ---------------------------------------------------------------- footer links + ads */

.footer-links { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin-top: 1rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--ink); }

.sidebar-column { display: grid; gap: 2rem; align-content: start; }

/* Space is reserved so the page doesn't jump when an ad loads. */
.ad { margin-top: 2.5rem; min-height: 100px; }
.ad-sidebar { margin-top: 0; min-height: 250px; }
@media (max-width: 52rem) { .ad-sidebar { display: none; } }

/* ---------------------------------------------------------------- how-to and questions under each tool */

.guide {
  margin-top: 4.5rem;
  padding-top: 2rem;
  border-top: 2px solid var(--ink);
}
.guide h2 {
  font-size: 1.6rem;
  letter-spacing: -.02em;
  margin: 0 0 1.25rem;
}
.guide h2 + .steps { margin-top: 0; }
.guide .steps + h2 { margin-top: 3rem; }

/* The steps really are a sequence, so they get big numbers. */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: .75rem;
  align-items: baseline;
}
.steps li::before {
  content: counter(step);
  font: 700 1.5rem/1 var(--display);
  color: var(--pine);
}

.faq { display: grid; gap: 1.5rem; }
.faq-item h3 {
  font: 700 1.1rem/1.35 var(--display);
  margin: 0 0 .3rem;
}
.faq-item p { margin: 0; color: var(--muted); }

/* ---------------------------------------------------------------- PDF editor */

.editor { margin-top: 1.5rem; }

/* The toolbar stays in view while scrolling through the pages. */
.editor-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem 1rem;
  padding: .7rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 18px -12px rgba(0, 0, 0, .35);
}
.editor-tools, .editor-actions, .editor-settings { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.editor-actions { margin-left: auto; }
.editor-settings:empty { display: none; }

.editor-bar button:not(.primary) {
  font: 700 .92rem/1 var(--body);
  padding: .55rem .75rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.editor-bar button:not(.primary):hover:not(:disabled) { border-color: var(--ink); }
.editor-bar button:disabled { opacity: .4; cursor: default; }
.editor-bar button[aria-pressed="true"] { background: var(--pine); border-color: var(--pine); color: var(--pine-ink); }
.editor-bar .primary { min-height: 2.5rem; padding: 0 1.1rem; font-size: 1rem; }

.setting { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; color: var(--muted); }
.setting[hidden] { display: none; }
.setting select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: .3rem .35rem;
}
.setting input[type="color"] { width: 2.1rem; height: 2.1rem; padding: 0; border: 1.5px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }

.editor-hint { color: var(--muted); font-size: .92rem; margin: .75rem 0 1rem; min-height: 1.4em; }

.pages { display: grid; gap: 1.25rem; justify-items: center; }
.page {
  position: relative;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18), 0 8px 24px -14px rgba(0, 0, 0, .4);
}
.page canvas { display: block; }
.layer { position: absolute; inset: 0; overflow: hidden; }
.editor[data-tool="text"] .layer { cursor: text; }
.editor[data-tool="whiteout"] .layer, .editor[data-tool="highlight"] .layer,
.editor[data-tool="rect"] .layer, .editor[data-tool="draw"] .layer, .editor[data-tool="image"] .layer { cursor: crosshair; }
/* While drawing, a finger draws instead of scrolling the page. */
.editor[data-tool="draw"] .layer, .editor[data-tool="rect"] .layer,
.editor[data-tool="whiteout"] .layer, .editor[data-tool="highlight"] .layer { touch-action: none; }

.item { position: absolute; box-sizing: border-box; touch-action: none; }
.editor[data-tool="select"] .item { cursor: move; }
.item-text { white-space: pre; line-height: 1.2; padding: 0; user-select: none; }
.item-whiteout { background: #fff; }
.item-highlight { opacity: .4; mix-blend-mode: multiply; }
.item-draw { overflow: visible; }
.item-image { user-select: none; }
.item.selected { outline: 2px solid var(--pine); outline-offset: 2px; }
.item-whiteout.selected { outline-style: dashed; }
.handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: var(--pine);
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
}

.text-editor {
  position: absolute;
  min-width: 2ch;
  white-space: pre;
  line-height: 1.2;
  outline: 2px dashed var(--pine);
  outline-offset: 2px;
  background: rgba(255, 255, 255, .6);
  cursor: text;
}

@media (max-width: 40rem) {
  .editor-actions { margin-left: 0; width: 100%; }
  .editor-actions .primary { margin-left: auto; }
}

/* A long list of files (big batches) scrolls inside its own box. */
.file-list.long { max-height: 24rem; overflow-y: auto; padding-right: .25rem; }
