/* Aetherstar styles.

   Structure only: layout and components. Identity (colors, fonts, the dusk
   background, banner, header) is in brand.css, which loads after this file.

   How this file is organised:
     2. Base elements
     3. Layout: page width and grids
     4. Components: buttons, forms, cards, tiles, tables, flash messages
     5. Page-specific: calendar, chat, applications
*/

/* ------------------------------------------------------------------ 1. Tokens
   Colors, fonts and the page background live in brand.css (loaded after
   this file). Every rule below reads them as var(--name). */

/* ------------------------------------------------------------------ 2. Base */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font: 16px/1.55 var(--font-body);
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0 0 0.5em;
}
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); }
h2 { font-size: 1.35rem; margin-top: 1.6em; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; }
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

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

/* Our input rules below set display:block, which would otherwise beat the
   browser's own rule for the HTML "hidden" attribute. */
[hidden] { display: none !important; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.5em; }
.lede { font-size: 1.1rem; color: var(--muted); max-width: 60ch; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent);
  color: var(--accent-ink); padding: 0.5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------------ 3. Layout */
.wrap {
  width: min(1120px, 100%);
  margin-inline: auto;
  padding-inline: 16px;
}
main.wrap { padding-block: 1.5rem 4rem; min-height: 70vh; }

/* The site header, navigation and footer are part of the Aetherstar
   identity, so they are styled in brand.css. */

.crumbs { margin-bottom: 0.5rem; font-size: 0.9rem; }

.two-col { display: grid; gap: 1.5rem; grid-template-columns: 1fr 320px; }
.detail { display: grid; gap: 2rem; grid-template-columns: 1fr 320px; }
.calendar-layout { display: grid; gap: 1.5rem; grid-template-columns: 1fr 340px; }
.app-layout { display: grid; gap: 1.5rem; grid-template-columns: 1fr 340px; }
.two-col > *, .detail > *, .calendar-layout > *, .app-layout > * { min-width: 0; }

@media (max-width: 860px) {
  .two-col, .detail, .calendar-layout, .app-layout { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ 4. Components */
.button {
  display: inline-block; text-align: center; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: 8px;
  padding: 0.55rem 1rem; font: 600 0.95rem var(--font-body);
  text-decoration: none;
}
.button:hover { filter: brightness(1.08); }
.button.ghost { background: transparent; color: var(--accent); }
.button.ghost:hover { background: var(--accent-soft); filter: none; }
.button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.button.danger:hover { background: var(--bad-soft); filter: none; }
.button.small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }

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

/* Forms */
label { display: block; font-weight: 500; font-size: 0.9rem; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400; }
input, select, textarea {
  display: block; width: 100%; margin-top: 0.3rem;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0.55rem 0.7rem; font: 400 1rem var(--font-body);
}
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0; }
textarea { resize: vertical; line-height: 1.5; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; }
legend { font-weight: 500; font-size: 0.9rem; padding-inline: 0.4rem; }

.stack { display: grid; gap: 1rem; }
.stack-tight { display: grid; gap: 0.6rem; }
.row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-narrow { max-width: 680px; }
.form-small { max-width: 400px; }
.check-grid { display: grid; gap: 0.4rem 1rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.inline-form { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin: 0.6rem 0; }
.inline-form input { margin: 0; width: auto; min-width: 220px; }

.flash {
  padding: 0.7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  background: var(--accent-soft); border: 1px solid var(--line);
}
.flash-success { background: var(--good-soft); }
.flash-error { background: var(--bad-soft); }
.flash ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }

.side-box {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.side-box h2 { margin-top: 0; font-size: 1.1rem; }
.side-box hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
.side-box .button { width: 100%; }

.badge {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600; background: var(--accent-soft);
  color: var(--accent); letter-spacing: 0.03em; text-transform: uppercase;
}

.empty {
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 2rem; text-align: center;
}

/* Home page: hero, search, subject tiles */
.hero { padding-block: 1.5rem 1rem; }
.hero h1 { max-width: 20ch; margin-bottom: 0.4em; }

.searchbar { display: flex; gap: 0.6rem; margin-bottom: 1.2rem; }
.searchbar input { margin: 0; font-size: 1.05rem; padding: 0.75rem 1rem; }
.searchbar .button { padding-inline: 1.5rem; }

.section-label {
  font: 600 0.78rem var(--font-body); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); margin: 1.2rem 0 0.5rem;
}

.tiles { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 0.35rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.8rem; text-decoration: none;
  color: var(--ink);
}
.tile:hover { border-color: var(--accent); }
.tile.active { border-color: var(--accent); background: var(--accent-soft); }
.tile-name { font-weight: 600; font-size: 0.92rem; line-height: 1.2; }
.tile-count {
  position: absolute; top: 0.6rem; right: 0.7rem; color: var(--muted);
  font: 500 0.8rem var(--font-mono);
}
.constellation line { stroke: var(--muted); stroke-width: 1.6; opacity: 0.7; }
.constellation circle { fill: var(--star); }
.tile.active .constellation line { stroke: var(--accent); opacity: 1; }

.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 0.35rem 0.85rem; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; font: 500 0.9rem var(--font-body); cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* "Who is it for?": a joined row of buttons, one of which is always active. */
.levels {
  display: inline-flex; max-width: 100%; overflow-x: auto;
  border: 1px solid var(--line); border-radius: 99px;
  background: var(--surface); padding: 3px; gap: 2px;
}
.level {
  padding: 0.35rem 1rem; border-radius: 99px; color: var(--ink);
  text-decoration: none; font: 600 0.9rem var(--font-body);
  white-space: nowrap;
}
@media (max-width: 480px) {
  .level { padding: 0.35rem 0.4rem; font-size: 0.75rem; }
}
.level:hover { background: var(--accent-soft); }
.level.active { background: var(--accent); color: var(--accent-ink); }

.more-filters { margin-top: 1rem; }
.more-filters summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--accent); }
.filter-grid {
  display: grid; gap: 0.8rem; margin-top: 0.8rem; align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.results-head {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 0.5rem; margin-top: 1.5rem;
}
.results-head h2 { margin: 0; }
.results-actions { display: flex; gap: 1rem; flex-wrap: wrap; align-items: baseline; }

.pager {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem;
}

/* Cards */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); margin-top: 1rem; }
.card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow); min-width: 0;
}
.card-top { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.card h3 { margin: 0.6rem 0 0.1rem; font-size: 1.15rem; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--accent); text-decoration: underline; }
.org { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
.blurb { font-size: 0.92rem; flex: 1; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem; padding: 0; margin: 0 0 0.9rem; }
.tag {
  display: inline-block; padding: 0.12rem 0.55rem; border-radius: 6px;
  font-size: 0.78rem; background: var(--bg); border: 1px solid var(--line);
  color: var(--muted); text-decoration: none;
}
.tag-subject { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.tag-level { color: var(--star); background: var(--star-soft); border-color: transparent; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.card-actions form { margin: 0; }

/* Deadlines: color is never the only signal; the text always says it too. */
.deadline { font: 500 0.78rem var(--font-mono); color: var(--muted); }
.deadline-soon { color: var(--star); font-weight: 600; }
.deadline-closed { color: var(--bad); }
.deadline-open { color: var(--good); }
.deadline-big { font: 700 1.5rem var(--font-display); margin: 0; }

/* Opportunity page */
.detail h1 { margin-top: 0.4rem; }
.body-text { font-size: 1.05rem; max-width: 65ch; }
.facts { display: grid; gap: 0.6rem; margin: 1.2rem 0; }
.facts div { display: grid; grid-template-columns: 110px 1fr; gap: 0.5rem; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: 0; }
.prompt-preview li { margin-bottom: 0.4rem; }
.experience { border-top: 1px solid var(--line); padding: 0.8rem 0; }
.experience header { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.experience p { margin: 0.3rem 0; max-width: 65ch; }
.experience form { margin: 0; }
.stars, .rating-summary { color: var(--star); letter-spacing: 0.05em; }
.rating-summary { font-size: 1rem; margin-left: 0.5rem; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
td.actions form { margin: 0; }
.admin-actions { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.error-page { text-align: center; padding-block: 4rem; }
.error-code { font-size: 4rem; color: var(--star); margin: 0; }

/* ------------------------------------------------------------------ 5. Pages */

/* Calendar */
.month-nav { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.8rem; }
.month-nav h2 { margin: 0; min-width: 11ch; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 0.8rem; }
.segmented a { padding: 0.35rem 0.8rem; font-size: 0.85rem; text-decoration: none; color: var(--ink); background: var(--surface); }
.segmented a[aria-current="true"] { background: var(--accent); color: var(--accent-ink); }

.month {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--surface);
}
.dow {
  padding: 0.4rem; text-align: center; font: 600 0.72rem var(--font-body);
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.day {
  min-height: 92px; padding: 0.3rem; border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.day:nth-child(7n) { border-right: 0; }
.day.blank { background: var(--bg); }  /* days outside this month */
.day.today { background: var(--accent-soft); }
.day-number { font: 500 0.78rem var(--font-mono); color: var(--muted); }
.day.today .day-number { color: var(--accent); font-weight: 700; }
.event {
  display: block; font-size: 0.72rem; line-height: 1.25; padding: 2px 5px;
  border-radius: 4px; background: var(--star-soft); color: var(--ink);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.event:hover { outline: 1px solid var(--star); }
.event.mine { background: var(--accent-soft); color: var(--accent); }
.upcoming { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.8rem; }
.upcoming a { display: block; font-weight: 500; }
.copy-row { margin-top: 1rem; }
.copy-field { display: flex; gap: 0.4rem; }
.copy-field input { margin: 0.3rem 0 0; font: 400 0.8rem var(--font-mono); }
.copy-field .button { width: auto; margin-top: 0.3rem; }

@media (max-width: 640px) {
  .day { min-height: 64px; padding: 0.15rem; }
  .event { font-size: 0; padding: 0; height: 6px; margin-top: 2px; background: var(--star); }
  .event.mine { background: var(--accent); }
}

/* Chat */
.chat { max-width: 760px; }
.chat-log { display: grid; gap: 0.9rem; margin-bottom: 1rem; }
.bubble { padding: 0.8rem 1rem; border-radius: var(--radius); max-width: 92%; }
.bubble p { margin: 0 0 0.5em; }
.bubble.assistant { background: var(--surface); border: 1px solid var(--line); }
.bubble.user { background: var(--accent); color: var(--accent-ink); justify-self: end; }
.bubble.thinking { color: var(--muted); font-style: italic; }
.examples { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chat-results { list-style: none; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.5rem; }
.chat-results li { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.chat-results a { font-weight: 600; }
.chat-form { display: flex; gap: 0.6rem; }
.chat-form input { margin: 0; }

/* Applications and word counter */
.app-list { display: grid; gap: 0.75rem; }
.app-row {
  display: grid; gap: 0.2rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.9rem 1.1rem; text-decoration: none; color: var(--ink);
}
.app-row:hover { border-color: var(--accent); }
.status {
  margin-left: 0.5rem; font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.1rem 0.5rem; border-radius: 99px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.status-submitted, .status-accepted { background: var(--good-soft); color: var(--good); border-color: transparent; }
.status-declined { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.status-in-progress { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.app-head { margin-bottom: 1rem; }
.total-words { font-size: 0.95rem; color: var(--muted); }

.prompt {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.prompt header { display: flex; justify-content: space-between; align-items: baseline; }
.prompt h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 0.4rem; font-family: var(--font-body); }
.prompt header form { margin: 0; }
.prompt-text { font-size: 1.02rem; font-weight: 600; margin-bottom: 0.5rem; }
.prompt textarea { margin-top: 0; font-size: 1rem; }

.counter { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; margin-top: 0.5rem; font-size: 0.9rem; }
.count { font-weight: 600; }
.save-state { margin-left: auto; font-size: 0.8rem; }
.counter.over .count { color: var(--bad); }
.counter.near .count { color: var(--star); }

.meter { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 0.4rem; }
.meter-fill { height: 100%; width: 0; background: var(--good); transition: width 0.15s; }
.counter.near + .meter .meter-fill { background: var(--star); }
.counter.over + .meter .meter-fill { background: var(--bad); }

.prompt-tools { display: flex; gap: 0.5rem; margin-top: 0.8rem; flex-wrap: wrap; }
.file-button { cursor: pointer; width: auto; }
.app-side .button.danger { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
