/* The one stylesheet of the PhD planner.

Phone width first: the rules without a media query are for a narrow screen, and the
rules under `min-width: 48rem` widen the layout. Light and dark follow the device
setting through `prefers-color-scheme`. No external fonts or scripts. */

:root {
  color-scheme: light dark;
  --bg: #f4f3ee;
  --surface: #ffffff;
  --surface-2: #eceae3;
  --text: #1d1d1b;
  --muted: #5d5c56;
  --line: #d9d7cf;
  --line-strong: #b3b1a8;
  --accent: #225cb0;
  --on-accent: #ffffff;
  --accent-soft: #e0eafa;
  --doing-bg: #fbeec6;
  --doing-text: #6b4a00;
  --doing-line: #dcc06a;
  --done-bg: #daefd9;
  --done-text: #1d5c29;
  --done-line: #9ccb9c;
  --suggest-text: #6a4ba6;
  --suggest-line: #b4a2db;
  --alert-bg: #fbe5e2;
  --alert-text: #882015;
  --alert-line: #e6a197;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141517;
    --surface: #1d1f23;
    --surface-2: #272a30;
    --text: #e8e6e0;
    --muted: #a4a29b;
    --line: #34373e;
    --line-strong: #4b4f58;
    --accent: #8db5ff;
    --on-accent: #0f1a33;
    --accent-soft: #1f2b45;
    --doing-bg: #3b3012;
    --doing-text: #f1d27a;
    --doing-line: #6a5622;
    --done-bg: #17301c;
    --done-text: #93d69e;
    --done-line: #2f5b38;
    --suggest-text: #c7b4f3;
    --suggest-line: #5e4c8e;
    --alert-bg: #3a1a17;
    --alert-text: #f4a79e;
    --alert-line: #7b2f27;
  }
}

/* Base */

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

html {
  font-family: var(--font);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  font-weight: 650;
}

h1 {
  font-size: 1.6rem;
}

p {
  margin: 0 0 0.75rem;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

svg,
img {
  max-width: 100%;
  height: auto;
}

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

/* Site header and page */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

/* The mark: the same three bars as static/icon.png, in the accent colours of the
   theme, so it follows the page into dark mode. */
.site-mark {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
}

.site-mark-tile {
  fill: var(--accent);
}

.site-mark-bar {
  fill: var(--on-accent);
}

.account {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.page {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.page.is-narrow {
  max-width: 26rem;
}

/* A heading that stands on its own at the top of a page, or between sections. The
   year heading sits in .year-head, so these rules do not reach it. */
.page > h1 {
  margin-bottom: 1rem;
}

.page > h2 {
  margin: 1.5rem 0 0.5rem;
}

/* An anchor in the address scrolls its element into view. The margin keeps the
   row above a comment or a comment form on the screen, so that the author sees
   which to-do, milestone or period the form belongs to. */
.item,
.period {
  scroll-margin-top: 1rem;
}

.comment,
.comment-form {
  scroll-margin-top: 5rem;
}

/* Forms and buttons */

input,
select,
textarea,
button {
  font: inherit;
}

.field {
  display: block;
  margin-bottom: 0.9rem;
}

.field-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

input:not([type="hidden"]),
textarea,
select {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

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

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  border-color: var(--accent);
}

.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.alert {
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--alert-line);
  border-radius: var(--radius);
  background: var(--alert-bg);
  color: var(--alert-text);
}

/* The answer to a change that went through, such as a saved file. */
.status {
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--done-line);
  border-radius: var(--radius);
  background: var(--done-bg);
  color: var(--done-text);
}

.note-text,
.help {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Setup page */

.qr {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  background: #ffffff;
}

.steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.steps > li {
  margin-bottom: 1rem;
}

/* Year tabs */

.year-tabs ul {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--line);
}

.year-tab {
  flex: 1 1 0;
  text-align: center;
}

.year-tab a {
  display: block;
  margin-bottom: -1px;
  padding: 0.55rem 0.5rem;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.year-tab a:hover {
  color: var(--text);
}

.year-tab.is-current a {
  border-bottom-color: var(--accent);
  color: var(--text);
}

/* Year heading and filters */

.year-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.year-heading {
  font-size: 1.5rem;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem 0.5rem;
  align-items: end;
  width: 100%;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.filter select {
  padding: 0.5rem 0.25rem 0.5rem 0.5rem;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 400;
  text-overflow: ellipsis;
}

.filters-buttons {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Periods */

.period {
  margin-bottom: 1.25rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

/* One column on a phone: the heading, then the controls, then the comments. On a
   wider screen the controls move beside the heading. */
.period-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem 1rem;
  align-items: start;
}

.period-number {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.period-title {
  font-size: 1.25rem;
  overflow-wrap: anywhere;
}

.period-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* The period's controls: Comment for every author, and Edit for the owner. */
.period-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.period-header .comments,
.period-header .comment-form {
  grid-column: 1 / -1;
}

.period h3 {
  margin: 1rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.no-periods {
  color: var(--muted);
}

/* To-do and milestone rows */

.items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr);
  gap: 0.2rem 0.75rem;
  align-items: start;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}

.item-main {
  grid-column: 2;
  min-width: 0;
}

.item-text {
  margin: 0;
  overflow-wrap: anywhere;
}

.state-done .item-text {
  color: var(--muted);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.75rem;
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.code {
  font-family: var(--mono);
  font-size: 0.85rem;
}

/* The item's controls: the link that opens the comment form. */
.item-side {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
}

.item-side:empty {
  display: none;
}

/* Comments and comment forms take the whole row on a phone, where the text column
   is narrow. On a wider screen they line up under the text. */
.item .comments {
  grid-column: 1 / -1;
}

/* The one-click state control: a button inside a form, which static/planner.js sends
   without a page load. */
.state {
  grid-column: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.25rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.state[data-state="doing"] {
  border-color: var(--doing-line);
  background: var(--doing-bg);
  color: var(--doing-text);
}

.state[data-state="done"] {
  border-color: var(--done-line);
  background: var(--done-bg);
  color: var(--done-text);
}

button.state {
  cursor: pointer;
}

button.state:hover {
  border-color: var(--accent);
}

.state-form {
  grid-column: 1;
  margin: 0;
}

.state-form .state {
  grid-column: auto;
}

.milestone-date {
  grid-column: 1;
  padding-top: 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
}

/* Marks */

.suggestion-mark,
.new-mark {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

.suggestion-mark {
  border: 1px dashed var(--suggest-line);
  color: var(--suggest-text);
}

.new-mark {
  background: var(--accent);
  color: var(--on-accent);
}

/* Comments */

.comments {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.comment {
  padding: 0.1rem 0 0.1rem 0.6rem;
  border-left: 3px solid var(--line-strong);
  font-size: 0.9rem;
}

.comment.is-new {
  border-left-color: var(--accent);
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.comment-author {
  color: var(--text);
  font-weight: 600;
}

/* The writer's Change and Delete controls go here. */
.comment-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.comment-text {
  margin: 0.1rem 0 0;
  overflow-wrap: anywhere;
}

/* The form that adds a comment to an item or a period, and the form that changes one.
   Each shows only while the address ends in its id, so the page needs no script for it. */
.comment-form {
  display: none;
  grid-column: 1 / -1;
  margin-top: 0.5rem;
}

.comment-form:target {
  display: block;
}

.comment-form-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

/* Delete opens a second button that deletes the comment, so one click deletes nothing. */
.comment-delete {
  display: inline;
  margin: 0;
}

.comment-delete summary {
  display: inline;
  cursor: pointer;
  list-style: none;
}

.comment-delete summary::-webkit-details-marker {
  display: none;
}

.comment-delete[open] summary {
  text-decoration: none;
  color: inherit;
}

.comment-delete form {
  display: inline;
  margin: 0 0 0 0.5rem;
}

/* A button that looks like the links beside it. */
.link-button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: inherit;
  text-decoration: underline;
}

.link-button:hover {
  border: 0;
}

.comment-link {
  font-size: 0.9rem;
}

/* Notes */

.notes-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 1.5rem;
}

.notes ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.95rem;
}

.note {
  margin: 0.2rem 0;
  overflow-wrap: anywhere;
}

.note .suggestion-mark {
  margin-left: 0.25rem;
}

/* Wider screens */

@media (min-width: 48rem) {
  .page {
    padding: 1.5rem 1.5rem 4rem;
  }

  .year-tab {
    flex: 0 0 auto;
  }

  .year-tab a {
    padding: 0.55rem 1rem;
  }

  .year-heading {
    font-size: 1.75rem;
  }

  .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    width: auto;
  }

  .filter select {
    width: auto;
    max-width: 20rem;
    padding: 0.5rem 0.6rem;
    font-size: 1rem;
  }

  .period {
    padding: 1.25rem 1.5rem;
  }

  .period-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .period-actions {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
  }

  .item {
    grid-template-columns: 5.25rem minmax(0, 1fr) auto;
  }

  .item-side {
    grid-column: 3;
    grid-row: 1;
    justify-content: flex-end;
  }

  .item .comments,
  .item .comment-form {
    grid-column: 2 / -1;
  }

  .notes-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Edit view and period changes (owner only) */

.period-edit textarea {
  min-height: 60vh;
  font-family: var(--mono);
  font-size: 0.9rem;
  white-space: pre;
  overflow-wrap: normal;
}

.edit-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.period-rename,
.period-remove {
  margin-top: 2rem;
}

.period-rename h2,
.period-remove h2 {
  margin-bottom: 0.5rem;
}

.period-remove input[type="checkbox"] {
  width: auto;
  margin-right: 0.4rem;
}

.plan-actions {
  margin-top: 1.5rem;
}

/* The sign-out list: one row per browser or agent, with its Sign out button at the right. */

.session-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.session {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.15rem 1rem;
  align-items: center;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
}

.session-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.session-date {
  color: var(--muted);
  font-size: 0.9rem;
}

.session form {
  grid-column: 2;
  grid-row: 1 / span 2;
  margin: 0;
}

.session-details {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
}

.session-details summary {
  cursor: pointer;
}
