/* =========================================================
   TUTORING REQUEST FORM
   Sidebar (steps + live answers) beside a one-step-at-a-time panel.
========================================================= */

.apply {
  flex: 1;
  padding: clamp(32px, 5vw, 64px) 0 clamp(72px, 9vw, 120px);
  /* Step slide-ins translate sideways; clip (not hidden) keeps the sidebar sticky */
  overflow-x: clip;
}

.apply-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: start;
}

/* =========================
   SIDEBAR
========================= */
.apply-side {
  position: sticky;
  top: calc(var(--header-h) + 28px);
}

.apply-title {
  margin: 10px 0 16px;
}

.apply-intro {
  color: #4d4a44;
  max-width: 40ch;
  margin-bottom: 32px;
}

.apply-steps {
  list-style: none;
  border-top: 1px solid var(--ink);
  margin-bottom: 28px;
}

.apply-step {
  border-bottom: 1px solid var(--line);
}

.apply-step button {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--muted);
}

.apply-step button:disabled {
  cursor: default;
}

.apply-step button:not(:disabled):hover .apply-step-name {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.apply-step-num {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 22px;
  padding: 0 7px;
  margin-top: 1px;
  font-family: var(--mono);
  font-size: 0.7rem;
  background: var(--tint);
  color: var(--muted);
  clip-path: var(--chamfer-sm);
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

.apply-step-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.apply-step-name {
  font-weight: 500;
  color: var(--muted);
}

.apply-step-value {
  font-size: 0.86rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.apply-step.is-done .apply-step-num {
  background: var(--hl);
  color: var(--ink);
}

.apply-step.is-done .apply-step-name {
  color: var(--ink-2);
}

.apply-step.is-current .apply-step-num {
  background: var(--ink);
  color: var(--paper);
}

.apply-step.is-current .apply-step-name {
  color: var(--ink);
}

.apply-help {
  font-size: 0.92rem;
  color: var(--muted);
}

.apply-help a {
  color: var(--ink);
  text-underline-offset: 3px;
}

/* =========================
   FORM PANEL
========================= */
.apply-form {
  position: relative;
  background: var(--card);
  border: 1px solid var(--ink);
  padding: clamp(24px, 4vw, 48px);
  box-shadow: 0 30px 60px -40px rgba(18, 18, 18, 0.45);
}

/* Corner cut at the logo's angle */
.apply-form::before {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 44px;
  height: 44px;
  background: linear-gradient(225deg, var(--hl) 50%, transparent 50%);
}

/* Spam honeypots: hidden from people, same as the previous form */
.hp {
  display: none !important;
}

.apply-progress {
  display: none;
}

/* Steps */
.form-step {
  animation: stepIn 0.5s var(--ease);
}

.form-step[data-dir="back"] {
  animation-name: stepBack;
}

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translateX(22px);
  }
}

@keyframes stepBack {
  from {
    opacity: 0;
    transform: translateX(-22px);
  }
}

.form-step.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

.step-head {
  margin-bottom: 28px;
}

.step-count {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 10px;
}

.step-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 3.6vw, 2.8rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 10px;
}

.step-title:focus {
  outline: none;
}

.step-hint {
  color: var(--muted);
  max-width: 54ch;
}

.step-error {
  margin-top: 18px;
  color: #a1260d;
  font-weight: 500;
}

.step-error:empty {
  display: none;
}

.step-error::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 9px;
  margin-right: 10px;
  background: currentColor;
  transform: skewX(-46deg);
}

/* =========================
   SUBJECT TILES
========================= */
.subject-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.subject-choice {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 18px 18px 20px;
  background: #fff;
  border: 1px solid var(--line);
  cursor: pointer;
  transition:
    border-color 0.3s var(--ease),
    transform 0.4s var(--ease),
    box-shadow 0.4s var(--ease);
}

.subject-choice:hover {
  border-color: var(--ink);
  transform: translateY(-3px);
}

.subject-choice-fig {
  display: block;
  width: 96px;
  height: 96px;
  border: 1px solid var(--ink);
  background-color: var(--card);
  background-image:
    linear-gradient(rgba(18, 18, 18, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 18, 18, 0.055) 1px, transparent 1px);
  background-size: 12px 12px;
}

.subject-choice-fig img {
  width: 100%;
  height: 100%;
}

.subject-choice-body {
  display: grid;
  gap: 4px;
}

.subject-choice-name {
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1;
  color: var(--ink);
}

.subject-choice-meta {
  font-size: 0.88rem;
  color: var(--muted);
}

.tick {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--tint);
  clip-path: var(--chamfer-sm);
  transition: background 0.3s var(--ease);
}

.tick::after {
  content: "";
  width: 11px;
  height: 6px;
  border-left: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateY(-2px) rotate(-45deg) scale(0);
  transition: transform 0.35s var(--ease);
}

.subject-choice:has(input:checked) {
  border-color: var(--ink);
  box-shadow: inset 0 -5px 0 var(--hl);
}

.subject-choice:has(input:checked) .tick {
  background: var(--hl);
}

.subject-choice:has(input:checked) .tick::after {
  transform: translateY(-2px) rotate(-45deg) scale(1);
}

.subject-choice:has(input:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* =========================
   CHOICE CHIPS (year, course, format)
========================= */
.choice-group {
  border: 0;
  min-width: 0;
}

.course-block {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  animation: stepIn 0.45s var(--ease);
}

.course-block .field-label {
  margin-bottom: 12px;
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.choices--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice {
  position: relative;
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 58px;
  padding: 12px 16px;
  background: var(--tint);
  clip-path: var(--chamfer);
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.choice:hover {
  background: rgba(18, 18, 18, 0.12);
}

.choice-label {
  font-weight: 500;
  color: var(--ink);
}

.choice-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.choice:has(input:checked) {
  background: var(--ink);
}

.choice:has(input:checked) .choice-label {
  color: var(--paper);
}

.choice:has(input:checked) .choice-sub {
  color: #b9b5ab;
}

.choice:has(input:checked)::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  background: linear-gradient(225deg, var(--hl) 50%, transparent 50%);
}

.choice:has(input:focus-visible) {
  box-shadow:
    inset 0 0 0 2px var(--ink),
    inset 0 0 0 4px var(--hl);
}

.choice.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.choice.is-disabled:hover {
  background: var(--tint);
}

.choice.is-disabled .choice-label {
  text-decoration: line-through;
}

/* Format rows */
.format-list {
  display: grid;
  gap: 18px;
}

.format-row {
  border: 0;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  min-width: 0;
}

.format-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.format-subject {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.format-subject span {
  font-family: var(--serif);
  font-size: 1.7rem;
  color: var(--ink);
}

.format-subject small {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.where-label {
  margin: 16px 0 10px;
}

.format-note {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

/* =========================
   SESSION LOGISTICS (step 3) + START/NOTES (step 4)
========================= */
.sub-group {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.sub-group .field-label,
.sub-group legend.field-label {
  display: block;
  margin-bottom: 12px;
}

.sub-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
}

.choices--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choices--compact {
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.choices--compact .choice {
  min-height: 44px;
  padding: 10px 12px;
}

.choices--compact .choice-label {
  font-size: 0.92rem;
}

/* =========================
   AVAILABILITY GRID (hourly, 9am–9pm)
========================= */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.preset {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  border: 0;
  background: var(--tint);
  clip-path: var(--chamfer-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.preset small {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
}

.preset:hover {
  background: rgba(27, 26, 23, 0.13);
}

.preset[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.preset[aria-pressed="true"] small {
  color: #c8c2b4;
}

.preset--clear {
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--muted);
}

.preset--clear:hover {
  background: none;
  color: var(--ink);
}

.preset:focus-visible {
  outline: none;
  box-shadow:
    inset 0 0 0 2px var(--ink),
    inset 0 0 0 4px var(--hl);
}

.avail {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(0, 1fr));
  grid-auto-rows: 30px;
  gap: 3px;
  user-select: none;
  -webkit-user-select: none;
}

.avail-corner {
  display: block;
}

.avail-day,
.avail-hour {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  transition: color 0.2s ease;
}

.avail-day {
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.avail-day-short {
  display: none;
}

.avail-hour {
  justify-self: end;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

.avail-day:hover,
.avail-hour:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cell {
  position: relative;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  touch-action: none; /* a finger drag on the hours selects instead of scrolling */
  transition: background 0.12s ease, border-color 0.12s ease;
}

/* Weekday school hours: faint hatching, still selectable */
.cell.is-school {
  background:
    repeating-linear-gradient(135deg, transparent 0 5px, rgba(27, 26, 23, 0.06) 5px 6px),
    #faf7f0;
}

.cell:hover {
  border-color: var(--ink);
}

/* Selected hours read like a highlighter band */
.cell[aria-pressed="true"] {
  background: var(--hl);
  border-color: rgba(27, 26, 23, 0.25);
}

.cell[aria-pressed="true"]:hover {
  border-color: var(--ink);
}

.cell:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
  z-index: 1;
}

.avail-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.avail-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.key {
  display: inline-block;
  width: 16px;
  height: 12px;
  border: 1px solid var(--line);
}

.key--on {
  background: var(--hl);
}

.key--school {
  background:
    repeating-linear-gradient(135deg, transparent 0 3px, rgba(27, 26, 23, 0.12) 3px 4px),
    #faf7f0;
}

.avail-summary {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--paper-2);
  font-size: 0.95rem;
  color: var(--ink-2);
}

.avail-summary strong {
  font-weight: 600;
  color: var(--ink);
}

.field.sub-group textarea {
  min-height: 72px;
}

/* =========================
   FIELDS
========================= */
.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.fields .field:first-child {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 8px;
}

.field-label {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.field-label span {
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.field input,
.field textarea {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a19d93;
}

.field input:hover,
.field textarea:hover {
  border-color: #a19d93;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(213, 245, 91, 0.75);
}

.field.is-invalid input {
  border-color: #a1260d;
}

.field-error {
  font-size: 0.86rem;
  color: #a1260d;
}

.field-error:empty {
  display: none;
}

/* =========================
   REVIEW
========================= */
.review {
  border-top: 1px solid var(--ink);
  margin-bottom: 28px;
}

.review-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: baseline;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.review-row dt {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.review-row dd {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.review-edit button {
  border: 0;
  background: none;
  font-size: 0.88rem;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.review-edit button:hover {
  color: #000;
  background: var(--hl);
}

/* =========================
   NAV BUTTONS
========================= */
.apply-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.apply-nav #nextBtn {
  margin-left: auto;
}

.btn--back {
  padding: 6px 22px 6px 7px;
}

.btn--back:hover .btn-arrow svg {
  transform: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* =========================
   LEAVE DIALOG
========================= */
.leave-dialog {
  margin: auto;
  max-width: 420px;
  width: calc(100% - 32px);
  padding: 32px;
  border: 1px solid var(--ink);
  background: var(--card);
  color: var(--ink-2);
}

.leave-dialog::backdrop {
  background: rgba(18, 18, 18, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.leave-dialog h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 10px;
}

.leave-dialog p {
  color: var(--muted);
  margin-bottom: 24px;
}

.leave-dialog[open] {
  animation: stepIn 0.35s var(--ease);
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 960px) {
  .apply-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .apply-side {
    position: static;
  }

  .apply-steps,
  .apply-help {
    display: none;
  }

  .apply-intro {
    margin-bottom: 0;
  }

  .apply-progress {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
  }

  .apply-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--paper-2);
  }

  .apply-progress-bar span {
    display: block;
    height: 100%;
    background: var(--ink);
    transition: width 0.5s var(--ease);
  }
}

@media (max-width: 560px) {
  .apply-form {
    margin: 0 calc(var(--gutter) * -1);
    border-left: 0;
    border-right: 0;
  }

  .subject-choices {
    grid-template-columns: minmax(0, 1fr);
  }

  .subject-choice {
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
  }

  .subject-choice-fig {
    width: 72px;
    height: 72px;
  }

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

  .avail {
    grid-template-columns: 40px repeat(7, minmax(0, 1fr));
    grid-auto-rows: 32px;
    gap: 2px;
  }

  .avail-day-long {
    display: none;
  }

  .avail-day-short {
    display: inline;
  }

  .avail-hour {
    padding-right: 4px;
    font-size: 0.72rem;
  }

  .sub-row,
  .choices--three {
    grid-template-columns: minmax(0, 1fr);
  }

  .review-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
  }

  .review-row dt {
    grid-column: 1 / -1;
  }

  .apply-nav .btn {
    min-height: 50px;
  }
}

/* Floated legends aren't drawn into the fieldset's top border, so the
   divider line sits above the label like every other sub-section */
.sub-group > legend {
  float: left;
  width: 100%;
}

.sub-group > legend + * {
  clear: both;
}

.avail button {
  -webkit-tap-highlight-color: transparent;
}

/* Phones/tablets: tell people how to scroll past the grid */
.touch-only {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .touch-only {
    display: inline;
  }
}

/* Same as .sub-group: keep each subject's heading below its divider line */
.format-row > legend {
  float: left;
  width: 100%;
}

.format-row > legend + * {
  clear: both;
}
