/* ==========================================================================
   SimpleClarity stylesheet
   A restrained, book-like interface for editing formal prose.
   No external fonts are loaded; everything uses local system typefaces.
   ========================================================================== */

:root {
  /* Palette. --accent is the single accent colour; change it here and the
     whole interface follows. Keep it dark enough to carry white text. */
  --bg: #faf9f6;            /* paper background */
  --panel: #ffffff;         /* writing surfaces */
  --panel-alt: #fbfaf7;     /* read-only surface */
  --border: #d9d5cb;        /* hairlines */
  --border-strong: #b9b3a4;
  --text: #21252a;          /* body ink */
  --muted: #6a6e75;         /* secondary text */
  --accent: #35507a;        /* understated ink blue */
  --accent-dark: #283e60;
  --accent-soft: rgba(53, 80, 122, 0.14);
  --danger: #8f2f2c;
  --danger-bg: #f7edeb;
  --danger-border: #ddb9b4;
  --warn: #7a5416;
  --warn-bg: #f8f1e2;
  --warn-border: #dcc99c;

  /* Type. Serif for prose and headings, system sans for controls. */
  --serif: Charter, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

::selection {
  background: #d5deec;
}

/* --------------------------------------------------------------------------
   Masthead and footer
   -------------------------------------------------------------------------- */

.masthead {
  border-bottom: 1px solid var(--border);
  padding: 44px 0 30px;
  text-align: center;
  background: var(--bg);
}

.site-name {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 10px;
  color: var(--text);
}

.tagline {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 46em;
  margin: 0 auto;
}

.site-foot {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 26px 0 40px;
  text-align: center;
}

.site-foot p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Workspace: two equal panels on desktop, stacked on narrow screens
   -------------------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 36px;
}

.panel {
  min-width: 0; /* allow panes to shrink inside the grid */
}

.panel-title {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-title label {
  cursor: pointer;
}

/* The two writing surfaces */

.pane {
  display: block;
  width: 100%;
  min-height: 380px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  resize: vertical;
}

.pane::placeholder {
  color: #9b9ea4;
  opacity: 1;
  font-style: italic;
}

.pane:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pane-output {
  background: var(--panel-alt);
}

.output-wrap {
  position: relative;
}

/* --------------------------------------------------------------------------
   Panel footers: word count, notes and buttons
   -------------------------------------------------------------------------- */

.panel-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  min-height: 40px;
}

.count-group {
  min-width: 0;
}

.word-count {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.word-count.over {
  color: var(--danger);
  font-weight: 600;
}

.limit-note {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--danger);
}

.status-note {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

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

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 9px 18px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Fallback for browsers without :focus-visible */
.button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button:focus:not(:focus-visible) {
  outline: none;
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.button-quiet {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--text);
}

.button-quiet:hover:not(:disabled) {
  background: #f1efe9;
}

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

/* --------------------------------------------------------------------------
   Alerts and loading state
   -------------------------------------------------------------------------- */

.alert {
  margin: 24px 0 0;
  padding: 11px 16px;
  border: 1px solid var(--danger-border);
  border-radius: 5px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 15px;
}

.alert.alert-warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
}

.busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 6px;
  background: rgba(251, 250, 247, 0.88);
  color: var(--muted);
  font-size: 15.5px;
}

.busy[hidden] {
  display: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--accent-soft);
  }
}

/* Not-found page */

.notfound {
  text-align: center;
  margin: 56px 0;
  font-size: 16.5px;
}

.notfound a {
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Responsive behaviour
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
    gap: 30px;
    margin-top: 28px;
  }

  .pane {
    min-height: 300px;
  }

  .masthead {
    padding: 34px 0 24px;
  }

  .site-name {
    font-size: 27px;
  }

  .tagline {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .panel-foot {
    align-items: stretch;
  }

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

  .actions .button {
    flex: 1 1 auto;
  }
}
