/* Aikana's hand-written stylesheet: design tokens, the shared shell and one section per view.
   No framework, no build step; class names are semantic and nesting is kept flat on purpose. */

:root {
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-900: #1e3a8a;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-200: #fecaca;
  --red-400: #f87171;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-900: #7f1d1d;
  --purple-600: #9333ea;
  --green-500: #22c55e;
}

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

body {
  margin: 0;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--gray-900);
}

h1,
p {
  margin: 0;
}

/* ---- Shared shell ---- */

.page {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-direction: row;
  gap: 1rem;
}

.nav a {
  font-size: 0.875rem;
  white-space: nowrap;
  color: var(--gray-600);
  text-decoration: none;
}

.nav a:hover {
  color: var(--gray-900);
}
.nav a.active {
  font-weight: 600;
  color: var(--blue-700);
}

.top-bar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ---- Shared building blocks ---- */

.input {
  border: 1px solid var(--gray-300);
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  background: white;
}

.input--full {
  width: 100%;
}
.input--year {
  width: 6rem;
}
.input--ects {
  width: 8rem;
}
.input--grow {
  flex: 1;
}

.btn {
  border: none;
  border-radius: 0.25rem;
  padding: 0.25rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  background: var(--blue-600);
  color: white;
}

.btn:hover {
  background: var(--blue-700);
}
.btn--danger {
  background: var(--red-600);
}
.btn--danger:hover {
  background: var(--red-700);
}

.btn--plain {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn--plain:hover {
  background: var(--gray-50);
}

.link {
  color: var(--blue-700);
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}
.link:hover {
  color: var(--blue-900);
}
.link--small {
  font-size: 0.75rem;
}
.link--danger {
  color: var(--red-700);
}
.link--danger:hover {
  color: var(--red-900);
}
.link--muted {
  color: var(--gray-600);
}
.link--muted:hover {
  color: var(--gray-900);
}

/* A submit button that reads as a plain text link (the header's Log out). */
.linkbtn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.875rem;
  color: var(--gray-600);
  cursor: pointer;
}

.linkbtn:hover {
  color: var(--gray-900);
}

.label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
}
.muted {
  font-size: 0.875rem;
  color: var(--gray-500);
}
.error {
  font-size: 0.875rem;
  color: var(--red-600);
}
.notice {
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--gray-500);
}
.page-title {
  font-weight: 600;
  font-size: 1.125rem;
}

/* ---- Forms and dialogs ---- */

dialog {
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  padding: 1rem;
  width: 24rem;
  max-width: calc(100vw - 2rem);
  box-shadow:
    0 20px 25px -5px rgb(0 0 0 / 0.1),
    0 8px 10px -6px rgb(0 0 0 / 0.1);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.35);
}

.dialog-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}
.dialog-note {
  font-size: 0.75rem;
  color: var(--gray-500);
}
.dialog-close {
  margin-top: 0.75rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.form-row {
  display: flex;
  gap: 0.5rem;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.form-actions--end {
  justify-content: flex-end;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 0.5rem;
}

.tab {
  border: none;
  background: none;
  border-radius: 0.25rem;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--gray-600);
  cursor: pointer;
}

.tab:hover {
  background: var(--gray-100);
}
.tab--active {
  background: var(--blue-600);
  color: white;
}
.tab--active:hover {
  background: var(--blue-700);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  max-width: 20rem;
}

.create-form {
  padding: 1rem;
}
.create-title {
  font-weight: 600;
  font-size: 1.125rem;
  margin-bottom: 0.5rem;
}
.create-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ---- Monday-first day calendar (a form field of day radio inputs) ---- */

.day-calendar {
  width: max-content;
}
.day-calendar-weekdays,
.day-calendar-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}

.day-calendar-weekday {
  display: flex;
  height: 1.75rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.day-calendar label {
  display: contents;
}

/* The radio is visually hidden; the span after it is the clickable day cell. */
.day-calendar input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.day-calendar-day {
  display: flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.day-calendar-day:hover {
  background: var(--gray-100);
}
.day-calendar input:checked + .day-calendar-day {
  background: var(--blue-600);
  color: white;
}
.day-calendar input:focus-visible + .day-calendar-day {
  outline: 2px solid var(--blue-600);
  outline-offset: 1px;
}
.day-calendar-spacer {
  display: inline-block;
  height: 2rem;
  width: 2rem;
}

/* ---- Hover tooltips (anchors carry data-tip, the tooltip is their data-tip-body child) ---- */

[data-tip] {
  position: relative;
}

[data-tip-body] {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  width: 14rem;
  flex-direction: column;
  gap: 2px;
  white-space: normal;
  overflow-wrap: break-word;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  padding: 0.75rem;
  font-size: 0.75rem;
  line-height: 1.4;
  font-weight: 400;
  color: var(--gray-800);
  text-align: left;
  box-shadow:
    0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);
  z-index: 20;
  pointer-events: none;
}

[data-tip]:hover [data-tip-body] {
  display: flex;
}

.tip-title {
  font-weight: 600;
  color: var(--gray-900);
}
.tip-sub {
  color: var(--gray-500);
}
.tip-topic {
  color: var(--gray-800);
}
.tip-notes {
  color: var(--gray-400);
  font-style: italic;
  margin-top: 0.25rem;
}

/* ---- Semester wall planner ---- */

.semester-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.semester-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  /* --months is set inline by the view: one column per month of the semester. */
  grid-template-columns: repeat(var(--months), minmax(8rem, 1fr));
  gap: 10px;
  padding: 1rem;
  align-content: stretch;
}

/* On a small screen the months stack vertically in calendar order instead of squeezing. */
@media (max-width: 48rem) {
  .semester-grid {
    grid-template-columns: 1fr;
  }
}

.month {
  display: flex;
  flex-direction: column;
}

.month-label {
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--gray-300);
  padding-bottom: 0.25rem;
  margin-bottom: 0.25rem;
}

.days {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.day {
  flex: 1 1 0;
  min-height: 1.75rem;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border-bottom: 1px solid var(--gray-100);
}

.day--weekend,
.day--blocked {
  background: var(--red-50);
}
.day--today {
  border-left: 4px solid var(--green-500);
}
.day--clickable {
  cursor: pointer;
}
.day--clickable:hover {
  background: var(--gray-100);
}

.day-week {
  width: 1.5rem;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-300);
}

.day-weekday {
  width: 2rem;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--gray-500);
}
.day-num {
  width: 1.25rem;
  flex-shrink: 0;
  font-size: 0.875rem;
}

.day-markers {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.day-note,
.day-conference {
  font-size: 0.75rem;
  padding-right: 0.5rem;
  white-space: nowrap;
}

.day-note {
  color: var(--red-600);
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-conference {
  color: var(--purple-600);
}

/* Lesson squares and Deadline donuts; the color itself is set inline from the view's palette (a Deadline's as
   `border-color`, since a donut is a colored ring with a transparent fill). */
.marker {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
}
.marker--lesson {
  border-radius: 0.125rem;
}
.marker--deadline {
  border-radius: 9999px;
  background: transparent;
  border: 2px solid var(--gray-400);
}
.marker--plain {
  background: var(--gray-400);
}

.legend {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  border-top: 1px solid var(--gray-200);
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--gray-600);
}

.legend-items {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
}

.legend-chip {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.25rem;
}
.legend-chip-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-markers {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  border-left: 1px solid var(--gray-200);
  padding-left: 1rem;
  margin-left: 1rem;
}

.legend-marker {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

/* ---- Courses page ---- */

.courses {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.courses-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.course-card {
  border: 1px solid var(--gray-200);
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
}
.course-head--clickable {
  cursor: pointer;
}
.course-head--clickable:hover {
  background: var(--gray-50);
}
.course-name {
  font-weight: 600;
  color: var(--gray-900);
}
.course-desc {
  font-size: 0.875rem;
  color: var(--gray-600);
}
.course-ects {
  font-size: 0.75rem;
  color: var(--gray-500);
}

.realizations {
  border-top: 1px solid var(--gray-100);
  margin-top: 0.5rem;
  padding-top: 0.25rem;
}
.realizations-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.realization-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
}
.realization-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.realization-link {
  font-size: 0.875rem;
  color: var(--gray-700);
  text-decoration: none;
}
.realization-link:hover {
  color: var(--blue-900);
}
.row-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.empty-note {
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* ---- Realizations weekly view: one card per week ---- */

.realization-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.realization-view > .error {
  padding: 0 1rem 0.25rem;
}

.view-bar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem 0.5rem;
}

.weeks {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  width: 100%;
  max-width: 76.8rem;
  margin: 0 auto;
  padding: 0 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.week-header {
  flex-shrink: 0;
  display: flex;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
}

/* The header reuses the card sections' classes for geometry, so each label sits over the section it names. */
.week-header .week-head,
.week-header .week-lessons,
.week-header .week-deadlines {
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}
.week-header .week-lessons,
.week-header .week-deadlines {
  border-left: none;
}

.week-card {
  flex-shrink: 0;
  display: flex;
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  background: white;
}

.week-card--blocked {
  background: var(--red-50);
  border-color: var(--red-200);
}
.week-card--current {
  border-left: 4px solid var(--green-500);
}

.week-head {
  width: 22rem;
  flex-shrink: 0;
  padding: 0.75rem;
}
.week-head--clickable {
  cursor: pointer;
  border-radius: 0.5rem 0 0 0.5rem;
}
.week-head--clickable:hover {
  background: var(--gray-100);
}
.week-card--blocked .week-head--clickable:hover {
  background: var(--red-100);
}

.week-headline {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.week-num {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}
.week-theme {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-800);
}
.week-dates {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  color: var(--gray-500);
  white-space: nowrap;
}
.week-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.flag {
  display: inline-block;
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 0.125rem;
  flex-shrink: 0;
}
.flag--holiday {
  background: var(--red-600);
}
.flag--conference {
  background: var(--purple-600);
}

.week-lessons {
  flex: 1;
  min-width: 0;
  min-height: 3rem;
  padding: 0.5rem 0.75rem;
  border-left: 1px solid var(--gray-100);
}

.week-lessons--clickable {
  cursor: pointer;
}
.week-lessons--clickable:hover {
  background: var(--gray-50);
}

.lesson {
  padding: 0.125rem 0;
}
.lesson--clickable {
  cursor: pointer;
}
.lesson-topic {
  color: var(--gray-900);
}
.lesson-when {
  font-size: 0.75rem;
  color: var(--gray-500);
}
.lesson-notes {
  font-size: 0.875rem;
  color: var(--gray-600);
}

.week-note {
  color: var(--red-600);
  font-style: italic;
}

.week-deadlines {
  width: 12rem;
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  border-left: 1px solid var(--gray-100);
}

.week-deadlines--clickable {
  cursor: pointer;
}
.week-deadlines--clickable:hover {
  background: var(--gray-50);
}
.week-card--blocked .week-deadlines--clickable:hover {
  background: var(--red-100);
}

.deadline {
  margin-bottom: 0.25rem;
}
.deadline:last-child {
  margin-bottom: 0;
}
.deadline--clickable {
  cursor: pointer;
}
.deadline-title {
  color: var(--gray-900);
}
.deadline-date {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* On a narrow screen the card's three sections stack instead of squeezing. */
@media (max-width: 40rem) {
  /* The stacked cards no longer align in three columns, so the header row is hidden. */
  .week-header {
    display: none;
  }
  .week-card {
    flex-direction: column;
  }
  .week-head,
  .week-deadlines {
    width: auto;
  }
  .week-head--clickable {
    border-radius: 0.5rem 0.5rem 0 0;
  }
  .week-lessons,
  .week-deadlines {
    border-left: none;
    border-top: 1px solid var(--gray-100);
  }
}
