/*
 * Taskmaster app — "page one of a well-made planner".
 * One left-aligned ~28rem column. On larger screens it sits on a single paper
 * sheet (1px rule, no shadow) over a cool desk tone, with a blue planner margin
 * rule down its left edge. Phones get a full-bleed page with a 1rem gutter.
 * Type: Public Sans (OFL, self-hosted; see fonts/PublicSans-OFL.txt).
 */

@font-face {
  font-family: "Public Sans";
  src: url("/assets/fonts/public-sans-latin-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --ink: #18223a; /* planner ink navy: headings, text, primary action */
  --muted: #4b5567;
  --line: #8b94a6; /* control borders, 3:1 on paper */
  --surface: #ffffff; /* paper */
  --desk: #f2f4f7; /* behind the sheet on larger screens */
  --rule: #e3e7ed; /* ruled lines */
  --margin-rule: #b4c6ec; /* the planner margin line */
  --canvas: #f6f6f3; /* read-only fields while pending */
  --accent: #1f5fbf; /* links, focus, completed checkbox */
  --action: #18223a;
  --action-hover: #26344f;
  --action-pending: #33415f;
  --accent-ink: #ffffff;
  --autofill: #eef3fb; /* calm tint instead of browser yellow */
  --error: #b3261e;
  --error-surface: #fdecea;
  --notice-surface: #e8f1fc;
  --focus: #1f5fbf;
  color-scheme: light;
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
}

body {
  margin: 0;
}

.page {
  position: relative;
  width: 100%;
  max-width: 28rem;
  margin-inline: auto;
  padding: 1.25rem 1rem 3rem;
}

/* Page header of the planner: the wordmark on a ruled line. */
.wordmark {
  margin: 0 0 2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* ------------------------------------------------------------ type */

h1 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.625rem;
}

h1 label {
  cursor: default;
  font: inherit;
  margin: 0;
}

.lede {
  margin: 0 0 2rem;
  color: var(--muted);
}

/* ------------------------------------------------------------ planner entry */

/* A ruled planner line with a ticked checkbox: the step just completed. */
.entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.75rem;
  padding: 0.75rem 0;
  border-block: 1px solid var(--rule);
  font-size: 0.9375rem;
  color: var(--ink);
}

.entry-box {
  position: relative;
  flex: 0 0 auto;
  width: 1.125rem;
  height: 1.125rem;
  border: 1.5px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
}

.entry-box::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

@media (forced-colors: active) {
  .entry-box::after {
    border-color: CanvasText;
  }
}

/* Directly under the page header: share its rule instead of doubling it. */
.wordmark + .entry {
  margin-top: -2rem;
  border-top: 0;
}

/* ------------------------------------------------------------ fields */

form {
  margin: 0;
}

.field {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted);
}

/* Onboarding: the question is the label, its hint sits between it and the textarea. */
h1 + .hint {
  margin: 0 0 0.75rem;
}

.hint.length {
  margin-top: 0.25rem;
}

.hint.length[data-state="met"] {
  color: var(--ink);
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea {
  display: block;
  width: 100%;
  min-height: 3rem;
  /* 1rem+ keeps iOS from zooming on focus. */
  font: inherit;
  font-size: 1.0625rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 6rem;
}

/* Inset shadow, not a thicker border: errors never shift the layout. */
input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: inset 0 0 0 1px var(--error);
}

input:autofill {
  box-shadow: inset 0 0 0 100vmax var(--autofill);
  -webkit-text-fill-color: var(--ink);
}

input[aria-invalid="true"]:autofill {
  box-shadow: inset 0 0 0 1px var(--error), inset 0 0 0 100vmax var(--autofill);
}

input[readonly],
textarea[readonly] {
  /* Pending submissions stay readable; only interaction is paused. */
  background: var(--canvas);
}

.field-error {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  line-height: 1.4;
  font-weight: 600;
  color: var(--error);
}

input[hidden],
.field-error[hidden],
.hint[hidden],
.reveal[hidden],
.reveal-icon[hidden] {
  display: none;
}

/*
 * Password shell: the bordered box holds the input and the eye button side by
 * side. The input keeps right padding so a password manager's icon (anchored
 * to the input's own right edge) never covers typed text, and never covers the
 * button, which sits outside the input box.
 */
.input-shell {
  display: flex;
  align-items: center;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
}

.input-shell > input[type] {
  flex: 1 1 auto;
  min-width: 0;
  min-height: calc(3rem - 2px);
  padding-right: 2.25rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
}

.input-shell:has(> input[aria-invalid="true"]) {
  border-color: var(--error);
  box-shadow: inset 0 0 0 1px var(--error);
}

.input-shell > input[aria-invalid="true"] {
  box-shadow: none;
}

.input-shell:has(> input[readonly]) {
  background: var(--canvas);
}

.input-shell > input[readonly] {
  background: transparent;
}

.input-shell:has(> input:autofill) {
  background: var(--autofill);
}

.input-shell > input:autofill {
  box-shadow: inset 0 0 0 100vmax var(--autofill);
}

/* Draw the focus ring around the whole shell where :has() is supported;
   otherwise the input keeps its own ring. */
@supports selector(:has(*)) {
  .input-shell > input:focus-visible {
    outline: none;
  }

  .input-shell:has(> input:focus-visible) {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }
}

/* Show/Hide password: a 44×44 icon button at the field's right edge. */
.reveal {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-right: 1px;
  padding: 0;
  border: 0;
  border-radius: 0.375rem;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.reveal:hover,
.reveal:focus-visible {
  color: var(--ink);
}

.reveal:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -3px;
}

/* ------------------------------------------------------------ messages */

.alert {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--error);
  background: var(--error-surface);
  border-radius: 0.25rem;
}

.notice {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--notice-surface);
  border-radius: 0.25rem;
}

.alert p,
.notice p {
  margin: 0;
}

.alert-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.status {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  color: var(--muted);
}

.status:empty {
  margin: 0;
}

.status--quiet,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 3rem;
  margin-top: 0.5rem;
  padding: 0.75rem 1.5rem;
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 600;
  border: 0;
  border-radius: 0.5rem;
  background: var(--action);
  color: var(--accent-ink);
  cursor: pointer;
}

.submit:hover,
.submit:active {
  background: var(--action-hover);
}

/* Pending keeps full contrast; a small spinner shows work is under way. */
.submit[aria-disabled="true"] {
  background: var(--action-pending);
  cursor: progress;
}

.submit[aria-disabled="true"]::before {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 2px solid rgb(255 255 255 / 0.45);
  border-top-color: var(--accent-ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@media (prefers-reduced-motion: reduce) {
  .submit[aria-disabled="true"]::before {
    animation: none;
  }
}

.alternate {
  margin: 1.5rem 0 0;
}

.logout {
  margin-top: 2rem;
}

.link-button {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

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

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

/* ------------------------------------------------------------ larger screens */

@media (min-width: 40rem) {
  :root {
    background: var(--desk);
  }

  /* The sheet: paper with a 1px rule and no shadow; content ~28rem wide. */
  .page {
    max-width: 33.25rem;
    margin-block: clamp(2rem, 8vh, 4.5rem);
    padding: 2rem 2rem 2.5rem 3.25rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 4px;
  }

  /* The planner margin rule. */
  .page::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2rem;
    width: 1px;
    background: var(--margin-rule);
  }

  /* Ruled lines run the full width of the sheet, across the margin rule. */
  .wordmark,
  .entry {
    margin-inline: -3.25rem -2rem;
    padding-inline: 3.25rem 2rem;
  }

  /* Checkboxes hang in the margin, the way they do in a paper planner. */
  .entry-box {
    position: absolute;
    left: 0.4375rem;
  }

  .entry {
    position: relative;
  }

  h1 {
    font-size: 2.25rem;
  }
}
