/* =========================================================================
   layout.css — page structure, buttons and form fields.
   ========================================================================= */

.site-header,
.site-main,
.site-footer {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding-inline: 16px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 20px 8px;
}

.brand {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.brand__accent {
  color: var(--accent);
}

.site-main {
  padding-block: 16px;
}

.site-footer {
  padding-block: 24px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Fixed banner if the app's JavaScript failed to load */
.load-error {
  position: fixed;
  inset: 16px 16px auto;
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--error);
  color: #fff;
  text-align: center;
}

.load-error a {
  color: inherit;
}

/* ---------- Screens ---------- */

.screen__title {
  margin: 0 0 16px;
  font-size: 1.25rem;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.paste-box {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.error-message {
  margin: 12px 0 0;
  color: var(--error);
}

/* ---------- File drop zone ---------- */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 32px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}

/* While a file is dragged over the page */
.drop-zone--active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.drop-zone__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.drop-zone__hint {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Loading a PDF ---------- */

.loading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 24px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.loading__text {
  flex: 1 0 100%;
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.loading__bar {
  flex: 1 1 200px;
  height: 8px;
  accent-color: var(--primary);
}

/* ---------- Library ---------- */

.library {
  margin-top: 24px;
}

.library__heading {
  margin: 0 0 8px;
  font-size: 1rem;
}

.library__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.library__item {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

/* The whole card is one big button: click anywhere to open */
.library__open {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;                /* lets long titles shrink and get "…" */
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.library__open:hover {
  border-color: var(--muted);
}

.library__title {
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.library__meta {
  color: var(--muted);
  font-size: 0.85rem;
}

/* Progress bar: a background gradient filled up to --progress */
.library__bar {
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--primary) var(--progress, 0%), var(--border) 0);
}

.library__delete {
  align-self: center;
  color: var(--muted);
}

.library__usage {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- "or paste text" divider ---------- */

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

/* ---------- Password dialog ---------- */

.dialog {
  width: min(400px, calc(100% - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

.dialog__title {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.dialog__message {
  margin: 0 0 12px;
  color: var(--muted);
}

.dialog__input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.dialog .button-row {
  justify-content: flex-end;
}

/* ---------- Reader screen header ---------- */

.reader-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.doc-title {
  flex: 1;
  min-width: 0;                /* lets the title shrink and end with "…" */
  margin: 0;
  overflow: hidden;
  font-size: 1.1rem;
  white-space: nowrap;
  text-overflow: ellipsis;   /* very long titles end with "…" */
}

.notice {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  font-size: 0.9rem;
}

/* ---------- Buttons ---------- */

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.button {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  border-color: var(--muted);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-text);
}

.button--primary:hover:not(:disabled) {
  border-color: var(--primary);
  filter: brightness(1.08);
}

.button--small {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 0.85rem;
}

/* A button that looks like a link (used inside notices) */
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* Keeps the Play/Pause button the same width when its label changes */
.button--wide {
  min-width: 110px;
}
