/* Theses: list and detail. Mobile first: base rules are the 390 px artboards,
   the min-width media query adds the 1280 px layout. */

/* ---------- Shared pieces ---------- */

.legend {
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; line-height: 1.5; }
.badge-open { padding: 1px 8px; background: #E3F5EC; color: #0B6B40; }
.badge-open i { width: 7px; height: 7px; border-radius: 50%; background: #12A060; }
.badge-taken { padding: 1px 8px; background: #EEEDF3; color: var(--ink); }
.badge-level { padding: 0 7px; border: 1.5px solid var(--ink); }

/* ---------- List ---------- */

.theses-list { padding-bottom: 0; }

/* Mobile: the filters are a full-width band under the masthead. */
.tl-side { margin: 0 -16px; padding: 14px 16px 4px; border-bottom: 1px solid var(--line); }
.filters { display: flex; flex-direction: column; }
.filters fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.filters legend, .f-status .legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.filters .opt { position: relative; display: block; flex: none; cursor: pointer; }
.filters .opt input, .taken-opt input {
  position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; clip-path: inset(50%);
}
.filters input:focus-visible + span { outline: var(--focus); outline-offset: 2px; }
.apply { margin: 8px 0 10px; }
.js .apply { display: none; }

.f-search label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 600; }
.search-box {
  display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 12px;
  border: 1.5px solid var(--ink); border-radius: var(--radius); color: var(--muted);
}
.search-box:focus-within { outline: var(--focus); outline-offset: 2px; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 15px; color: var(--ink); background: transparent; }

/* Wraps: the Italian words are longer, and the chips must not run into each other. */
.f-row { display: flex; flex-wrap: wrap; gap: 8px; overflow-x: auto; padding: 15px 5px 7px; margin: -5px -5px 0; scrollbar-width: none; }
.f-level .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.level-chip, .taken-box {
  display: flex; align-items: center; min-height: 36px; padding: 0 14px; border: 1.5px solid var(--field);
  border-radius: var(--radius); background: var(--white); color: var(--ink);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.opt input:checked + .level-chip { background: var(--ink); border-color: var(--ink); color: var(--white); }
.f-status { flex: none; }
.taken-opt { display: block; cursor: pointer; }
.taken-box { border-style: dashed; font-weight: 500; }
.taken-box .switch { display: none; }
.taken-opt .when-on, .taken-opt .when-off { display: none; }
.taken-opt input:checked + .taken-box .when-on, .taken-opt input:not(:checked) + .taken-box .when-off { display: inline; }

.f-topic .opts { display: flex; gap: 8px; overflow-x: auto; padding: 5px 5px 9px; margin: -5px; scrollbar-width: none; }
.topic-row {
  display: flex; align-items: center; min-height: 36px; margin: 2px 3px; padding: 0 14px; white-space: nowrap;
  border: 1.5px solid var(--amber); border-radius: 999px;
  background: var(--white); color: var(--ink); font-size: 14px; font-weight: 500;
}
/* All topic options look the same: white with an amber border; the selected one is filled amber. */
.opt:hover .topic-row { background: var(--amber-tint); }
.opt input:checked + .topic-row { background: var(--amber); }

.count-row-mobile {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 0; font-size: 13px; color: var(--muted);
}
.count-row-mobile strong { color: var(--ink); }

.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.chip-remove {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--lavender); color: var(--blue); font-size: 14px; font-weight: 600; text-decoration: none;
}
.chip-remove:hover { background: var(--blue); color: var(--white); }
.chip-remove .x { font-size: 18px; line-height: 1; }

.t-cards { margin: 0; padding: 6px 0 40px; list-style: none; }
.t-card {
  display: flex; flex-direction: column; gap: 12px; padding: 16px 0 18px; border-bottom: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.t-card:hover { color: var(--ink); }
.t-card.taken { opacity: .8; }
/* The bar on top of the card: the colour of the main topic with three bars, or
   the editor's picture, and the availability and level at the top right.
   Always 5:1 (a card is 358 px wide and 72 high on a phone, about 410 by 82
   on a desktop), so the 5:1 crop of the picture is seen whole. On a tablet a
   single column is wider, and the height is held, which trims the picture a
   little at the top and bottom. */
.t-cover {
  position: relative; flex: none; display: flex; align-items: flex-end; aspect-ratio: 5 / 1; max-height: 104px; padding: 0 14px;
  overflow: hidden; background: var(--cover-bg);
}
.t-cover-img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
/* Solid chips, so they read over any picture. */
.t-flags { position: absolute; top: 8px; right: 8px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.t-flags .badge { padding-top: 1px; padding-bottom: 1px; }
.t-flags .badge-level { padding: 0 7px; background: var(--white); }
.t-bars { display: flex; gap: 6px; align-items: flex-end; height: 100%; }
.t-bars span { width: 9px; background: var(--cover-fg); transition: transform .4s cubic-bezier(.2, .8, .2, 1); }
.t-bars span:nth-child(1) { height: var(--h1); }
.t-bars span:nth-child(2) { height: var(--h2); }
.t-bars span:nth-child(3) { height: var(--h3); }
.t-body { flex: 1; min-width: 0; display: block; }
.t-title { display: block; font-family: var(--font-display); font-size: 17px; line-height: 1.3; font-weight: 600; }
.t-pitch { display: block; margin-top: 4px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.t-topics { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.t-topics .chip { padding: 1px 8px; font-size: 12px; }
.t-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--muted); }
.t-sups { display: flex; align-items: center; min-width: 0; }
.avatars { display: flex; padding-right: 6px; }
.avatars .av, .sup-avatar {
  display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 50%;
  background: var(--lavender); color: var(--blue); font-weight: 700;
}
.avatars .av { width: 26px; height: 26px; margin-right: -6px; border: 2px solid var(--white); font-size: 10px; }
/* A supervisor's photo replaces the initials. */
.av img, .sup-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.t-sups .names { margin-left: 8px; }
.t-foot .arrow { color: var(--blue); }

.t-empty { padding: 40px 0; text-align: center; }
.t-empty p { margin: 6px 0 16px; color: var(--muted); }
.t-empty .big { margin: 0; font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--ink); }

/* ---------- Detail ---------- */

.thesis-head { position: relative; padding-top: 12px; padding-bottom: 22px; }
.t-head-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.t-head-badges .badge { padding-top: 2px; padding-bottom: 2px; }
.t-head-badges .badge-open { padding: 3px 10px; }
.t-head-badges .badge-level { padding: 2px 10px; border-color: var(--white); }
.t-head-badges .chip { padding-top: 2px; padding-bottom: 2px; font-size: 12px; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .55); }
.thesis-head h1 { margin: 10px 0 0; max-width: 330px; font-size: 28px; line-height: 1.15; font-weight: 700; letter-spacing: -.015em; }

/* The picture of the thesis, in the blue header under the title: the same 5:1
   as the card, as wide as the page, at most 220 px high. */
.t-hero { width: 100%; margin-top: 18px; aspect-ratio: 5 / 1; max-height: 220px; overflow: hidden; background: var(--blue-hover); }
.t-hero img { display: block; width: 100%; height: 100%; object-fit: cover; }

.thesis-page { display: flex; flex-direction: column; padding-bottom: 40px; }
.thesis-aside { order: -1; }
.thesis-main { min-width: 0; padding-top: 28px; }

.sup-box { padding-top: 22px; }
.sup-row { display: flex; align-items: center; gap: 12px; }
.sup-row + .sup-row { margin-top: 12px; }
.sup-avatar { flex: none; width: 48px; height: 48px; font-family: var(--font-display); font-size: 16px; }
.sup-row-label { display: block; font-size: 12px; color: var(--muted); }
.sup-name { display: block; font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--ink); text-decoration: none; }
a.sup-name:hover { color: var(--blue); }
.sup-role { display: block; font-size: 14px; color: var(--muted); }
.sup-ext { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.sup-ext strong { color: var(--ink); font-weight: 500; }
.sup-box .contact { display: flex; width: 100%; min-height: 52px; margin-top: 16px; gap: 10px; }
.facts { margin: 20px 0 0; font-size: 14px; }
.facts div { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 12px; }
.facts div + div { margin-top: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }

.t-section + .t-section, .t-section + .t-more, .t-more + .t-section { margin-top: 18px; }
.t-section h2 {
  margin: 0 0 10px; padding-top: 14px; border-top: 2px solid var(--ink);
  font-size: 22px; line-height: 1.6; font-weight: 700;
}
.t-section h2.t-plain { padding-top: 0; border-top: 0; }
.t-intro { padding-top: 14px; border-top: 2px solid var(--ink); }
.t-section .prose { font-size: 16px; line-height: 1.65; }
.t-section .prose p { margin: 0 0 14px; }
.t-section .prose > :last-child { margin-bottom: 0; }

/* Numbered steps: an ordered list in the text becomes numbered tiles. */
.t-section .prose > ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; counter-reset: step; }
.t-section .prose > ol > li { position: relative; padding: 2px 0 0 40px; min-height: 28px; font-size: 15px; line-height: 1.55; counter-increment: step; }
.t-section .prose > ol > li::before {
  content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: 0;
  display: flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  background: var(--blue); color: var(--white); font-family: var(--font-display); font-size: 13px; font-weight: 700;
}
.t-section .prose > ol > li p { margin: 0; }

.t-more { margin-top: 30px; padding: 20px; background: var(--ink); color: var(--white); }
.t-more .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; color: var(--amber); }
.t-more h2 { margin: 6px 0 8px; font-size: 19px; line-height: 1.3; font-weight: 600; }
.t-more ul { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.t-more li { display: flex; gap: 10px; align-items: baseline; }
.t-more li::before { content: ""; flex: none; width: 7px; height: 7px; background: var(--amber); }
.t-more a { color: #D6D1F2; text-decoration: none; }
.t-more a:hover { color: var(--white); text-decoration: underline; }

.t-section.t-links { margin-top: 30px; }
.t-links h2 { margin-bottom: 6px; }
.lk {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 0;
  border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.lk:hover { background: var(--tint); color: var(--ink); }
.lk strong { font-weight: 600; }
.lk .note { color: var(--muted); }
.lk .go { color: var(--blue); }

.t-section.t-related { margin-top: 30px; }
.t-related h2 { margin-bottom: 12px; }
.t-related ul { display: flex; gap: 12px; overflow-x: auto; margin: 0; padding: 0 0 4px; list-style: none; }
.t-related li { flex: none; width: 250px; }
.t-related a { display: block; height: 100%; padding: 16px; border: 1.5px solid var(--line); color: var(--ink); text-decoration: none; }
.t-related a:hover { border-color: var(--blue); color: var(--ink); }
.t-related .meta { display: block; font-size: 12px; font-weight: 600; color: var(--blue); }
.t-related .title { display: block; margin-top: 4px; font-family: var(--font-display); font-weight: 600; line-height: 1.3; }

/* ---------- Desktop ---------- */

@media (min-width: 900px) {
  .legend { margin-bottom: 8px; }

  .theses-list { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; padding-top: 40px; padding-bottom: 80px; }
  .tl-side { flex: 1 1 250px; margin: 0; padding: 0; border: 0; }
  .tl-main { flex: 999 1 640px; min-width: 0; }

  .filters { gap: 18px; }
  .filters legend, .f-status .legend {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none; float: none; padding: 0;
    font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    margin-bottom: 6px; white-space: normal;
  }
  /* Search, Level, Status, Topic. */
  .f-search { order: 1; }
  .f-row { display: contents; }
  .f-level { order: 2; }
  .f-status { order: 3; }
  .f-topic { order: 4; }
  .apply { order: 5; margin: 0; }
  .f-search label { margin-bottom: 6px; }
  .search-box { height: 46px; }

  .f-level .opts { flex-wrap: wrap; }
  .level-chip { min-height: 34px; }
  .f-topic .opts { flex-direction: column; gap: 2px; overflow: visible; padding: 0; margin: 0; }
  .topic-row {
    justify-content: space-between; min-height: 34px; margin: 0; padding: 0 12px; border-radius: 0;
    font-size: 13px; font-weight: 400;
  }
  .topic-row .name { font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

  .taken-box { min-height: 34px; padding: 0; gap: 10px; border: 0; background: transparent; font-size: 15px; font-weight: 400; }
  .taken-box .switch {
    display: flex; align-items: center; width: 40px; height: 22px; padding: 0 3px; border-radius: 11px;
    background: var(--field); transition: background .2s ease;
  }
  .taken-box .switch::after { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--white); transition: transform .2s ease; }
  .taken-opt input:checked + .taken-box .switch { background: var(--blue); }
  .taken-opt input:checked + .taken-box .switch::after { transform: translateX(18px); }

  .count-row {
    display: flex !important; justify-content: space-between; align-items: baseline; gap: 16px;
    padding-bottom: 14px; border-bottom: 3px solid var(--ink);
  }
  .count-row h2 { margin: 0; font-size: 22px; font-weight: 700; }
  .count-row span { font-size: 14px; color: var(--muted); }
  .active-filters { margin-top: 16px; }

  .t-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-top: 24px; padding: 0; }
  .t-card {
    flex-direction: column; gap: 0; height: 100%; padding: 0; border: 1.5px solid var(--line); background: var(--white);
    transition: border-color .2s ease, transform .3s cubic-bezier(.2, .8, .2, 1);
  }
  .t-card:hover { border-color: var(--blue); transform: translateY(-3px); }
  .t-card:hover .t-bars span { transform: translateY(-10px); }
  .t-card:hover .arrow { transform: translateX(6px); }
  .t-cover { padding: 0 20px; }
  .t-flags { top: 10px; right: 12px; }
  .t-bars span { width: 12px; margin-bottom: -10px; }
  .t-bars { gap: 8px; }
  .t-body { display: flex; flex-direction: column; flex: 1; padding: 18px 20px 20px; }
  .t-title { font-size: 20px; line-height: 1.25; }
  .t-pitch { flex: 1; margin-top: 6px; font-size: 15px; }
  .t-foot { margin-top: 16px; font-size: 14px; }
  .avatars .av { width: 28px; height: 28px; font-size: 11px; }

  .t-empty { padding: 56px 0; }
  .t-empty .big { font-size: 22px; }

  /* Detail */
  .thesis-head { padding-top: 20px; padding-bottom: 36px; }
  .t-head-badges { gap: 8px; margin-top: 12px; }
  .t-head-badges .badge, .t-head-badges .chip { font-size: 13px; }
  .t-head-badges .chip { padding: 3px 10px; }
  .thesis-head h1 { max-width: 860px; margin-top: 12px; font-size: 48px; line-height: 1.1; letter-spacing: -.025em; }

  .thesis-page { flex-direction: row; flex-wrap: wrap; gap: 56px; padding-top: 48px; padding-bottom: 72px; }
  .thesis-main { flex: 999 1 600px; padding-top: 0; }
  .thesis-aside {
    order: 0; flex: 1 1 300px; position: sticky; top: 24px; align-self: flex-start;
    display: flex; flex-direction: column; gap: 20px;
  }
  .sup-box { padding: 24px; border: 1.5px solid var(--ink); }
  .sup-label { margin: 0 0 12px; color: var(--muted); }
  .sup-avatar { width: 52px; height: 52px; font-size: 18px; }
  .sup-name { font-size: 19px; }
  .sup-box .contact { margin-top: 20px; }
  .facts { margin-top: 22px; font-size: 15px; }
  .facts div { display: block; }
  .facts div + div { margin-top: 12px; }
  .facts dt { font-size: 13px; }

  .t-section + .t-section, .t-section + .t-more, .t-more + .t-section { margin-top: 36px; }
  .t-section h2 { margin-bottom: 12px; padding-top: 16px; border-top-width: 3px; font-size: 28px; letter-spacing: -.015em; }
  .t-intro { padding-top: 16px; border-top-width: 3px; }
  .t-section .prose { font-size: 18px; }
  .t-section .prose > p, .t-section .prose > ul { max-width: 720px; }
  .t-section .prose p { margin-bottom: 16px; }
  .t-section .prose > ol { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 6px; }
  .t-section .prose > ol > li { padding: 18px 18px 18px 66px; background: var(--tint); font-size: 16px; line-height: 1.5; }
  .t-section .prose > ol > li::before { left: 18px; top: 18px; width: 34px; height: 34px; font-size: 14px; }

  .t-more { margin-top: 36px; padding: 28px 32px; }
  .t-more .eyebrow { font-size: 13px; letter-spacing: .12em; }
  .t-more h2 { margin: 8px 0 14px; font-size: 22px; }
  .t-more ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px 28px; font-size: 15px; }
  .t-more li::before { width: 8px; height: 8px; }

  .t-section.t-links { margin-top: 36px; }
  .t-links h2 { margin-bottom: 6px; padding-top: 16px; border-top-width: 3px; font-size: 22px; }
  .t-section.t-related { margin-top: 48px; }
  .t-related h2 { margin-bottom: 16px; font-size: 22px; }
  .t-related ul { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; overflow: visible; padding: 0; }
  .t-related li { width: auto; }
  .t-related a { padding: 20px; }
  .t-related .meta { font-size: 13px; }
  .t-related .title { margin-top: 6px; font-size: 18px; }
}
