/* Faculty of Science Annual Reports — the site's stylesheet.
   The colours are those of the original design. */
:root {
  --black: #000000;
  --gold: #EBB733;
  --navy: #003366;
  --blue: #08488F;
  --ochre: #BB7900;
  --green: #55891A;
  --red: #B31B34;
  --grey: #D9D9DC;
  --text: #1a1a1a;
  --muted: #5a5a5a;
  --line: #c9c9cf;
  --white: #ffffff;
  --radius: 6px;
  --page: 1100px;
}

* { box-sizing: border-box; }

html { font-size: 16px; }
body {
  margin: 0;
  background: var(--ochre);
  color: var(--text);
  font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
  line-height: 1.45;
}

a { color: var(--blue); }
a:hover { text-decoration: none; }

.frame { width: min(var(--page), 100% - 20px); margin: 0 auto; background: var(--white);
         min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header: logo and site name, Home and user menu ─────────────────────── */
.site-header { background: var(--black); color: var(--white);
               display: flex; align-items: center; gap: 1rem;
               padding: .6rem 1.25rem; }
.site-header .logo img { display: block; height: 44px; }
.site-header .title { flex: 1; min-width: 0; text-decoration: none; color: var(--white); }
.site-header .title .faculty { display: block; color: var(--gold); font-family: Georgia, serif;
                               font-style: italic; font-weight: bold; font-size: .95rem; }
.site-header .title .site { display: block; font-size: 1.35rem; letter-spacing: .01em; }

.header-actions { display: flex; align-items: center; gap: .25rem; }
.header-actions a, .user-menu > summary {
  color: var(--white); text-decoration: none; display: flex; align-items: center; gap: .45rem;
  padding: .45rem .7rem; border-radius: var(--radius); cursor: pointer; font-size: .95rem;
}
.header-actions a:hover, .user-menu > summary:hover,
.user-menu[open] > summary { background: rgba(255, 255, 255, .14); }
.header-actions svg { width: 22px; height: 22px; flex: none; }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu .caret { font-size: .7rem; opacity: .8; }
.user-menu .avatar { width: 28px; height: 28px; border-radius: 50%; background: #3d4a5c;
                     display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.user-menu .avatar svg { width: 24px; height: 24px; }
.user-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 15rem;
                   background: var(--white); color: var(--text); border-radius: var(--radius);
                   box-shadow: 0 6px 24px rgba(0, 0, 0, .25); padding: .4rem 0; }
.user-menu .menu .who { padding: .5rem 1rem .6rem; border-bottom: 1px solid var(--line);
                        font-size: .85rem; color: var(--muted); }
.user-menu .menu .who strong { display: block; color: var(--text); font-size: .95rem; }
.user-menu .menu a { display: block; padding: .55rem 1rem; color: var(--text); text-decoration: none; }
.user-menu .menu a:hover { background: var(--grey); }

/* ── Section bar: the portal's sections ─────────────────────────────────── */
.section-bar { background: var(--navy); display: flex; overflow-x: auto; scrollbar-width: thin; }
.section-bar a { color: var(--white); text-decoration: none; padding: .7rem 1.1rem;
                 white-space: nowrap; font-size: .9rem; letter-spacing: .03em;
                 text-transform: uppercase; border-bottom: 3px solid transparent; }
.section-bar a:hover { background: rgba(255, 255, 255, .1); }
.section-bar a.current { border-bottom-color: var(--gold); background: rgba(255, 255, 255, .08); }

/* ── Status line: success messages, problems with fields ──────────────────
   Its height is reserved, so that a message doesn't move the page.  "Saved"
   flashes, then fades to a pale green within a second. */
.status { min-height: 2.6rem; padding: .5rem 1.25rem 0; }
.status .msg { padding: .3rem .8rem; border-radius: var(--radius); border-left: 5px solid; font-size: .9rem; }
.status .msg + .msg { margin-top: .3rem; }
.status .msg.ok { background: #f1f7ea; border-color: #9fc27a; color: #4d6338;
                  animation: saved-flash 1s ease-out; }
.status .msg.problem { background: #fbeaec; border-color: var(--red); color: #7d1022;
                       animation: problem-flash 1s ease-out; }
.status .msg.warning { background: #fdf5e1; border-color: var(--gold); color: #6b4d00;
                       animation: warning-flash 1s ease-out; }
.status .msg.pending { background: #f2f3f6; border-color: var(--line); color: var(--muted); animation: none; }
@keyframes problem-flash {
  from { background: #f3a3b0; border-color: var(--red); color: #4a0612; }
  to   { background: #fbeaec; border-color: var(--red); color: #7d1022; }
}
@keyframes warning-flash {
  from { background: #f5d77e; color: #4a3500; }
  to   { background: #fdf5e1; color: #6b4d00; }
}
@keyframes saved-flash {
  from { background: #9fd479; border-color: var(--green); color: #1d3a0a; }
  to   { background: #f1f7ea; border-color: #9fc27a; color: #4d6338; }
}

/* ── Content ───────────────────────────────────────────────────────────── */
main { flex: 1; padding: .6rem 1.25rem 2rem; }
main h1 { color: var(--blue); font-size: 1.7rem; margin: .2rem 0 1.2rem; font-weight: normal; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.card { display: block; border: 1px solid var(--line); border-radius: var(--radius);
        padding: 1rem 1.1rem; text-decoration: none; color: var(--text);
        border-top: 4px solid var(--navy); transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .12); transform: translateY(-1px); }
.card h3 { margin: 0 0 .35rem; color: var(--blue); font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }

/* ── Content of the pages (headings, forms and tables as on the old pages) ─ */
main { font-size: .9rem; }
main::after { content: ""; display: block; clear: both; }
main h2 { color: var(--blue); font-size: 1.6rem; font-weight: normal; margin: .2rem 0 .6rem; }
main h3 { color: var(--blue); font-size: 1.2rem; margin: 1.2rem 0 .5rem; }
main h4 { color: var(--blue); font-size: 1.05rem; margin: 1rem 0 .4rem; }
main h5 { color: var(--blue); font-size: .95rem; margin: .8rem 0 .3rem; }
main h1 + h3, main h2 + h3 { margin-top: .3rem; }
main img { border: none; }
main fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem;
                padding: .6rem .9rem .9rem; min-width: 0; }
main legend { color: var(--navy); padding: 0 .4rem; }
main input, main select, main textarea, main button { font: inherit; max-width: 100%; }
main input[type=text], main input[type=password], main input[type=email], main select, main textarea {
  border: 1px solid #9a9aa3; border-radius: 4px; padding: .25rem .4rem; background: var(--white); }
main textarea { width: 100%; }
main input[type=submit], main input[type=button], main button {
  background: var(--navy); color: var(--white); border: 1px solid var(--navy); border-radius: 4px;
  padding: .35rem .9rem; cursor: pointer; }
main input[type=submit]:hover, main input[type=button]:hover, main button:hover { background: var(--blue); }
main input:focus, main select:focus, main textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
main table { border-collapse: collapse; }
/* Fields: red text while not valid (js/checks.js), a red frame where the
   server found a problem. */
main input.bad, main textarea.bad { color: var(--red); }
main input.total { background: #f2f3f6; border-color: var(--line); font-weight: bold; text-align: right; }
main [aria-invalid="true"] { border-color: var(--red) !important; box-shadow: 0 0 0 1px var(--red); }
main ::placeholder { color: #a5a5ad; }
.date-wrap { position: relative; display: inline-flex; align-items: center; gap: .25rem; }
.date-wrap input[type=text] { width: 8.5em; }
.date-wrap .date-button { background: none !important; border: none !important; color: var(--navy) !important;
                          padding: .15rem !important; cursor: pointer; line-height: 0; }
.date-wrap .date-button svg { width: 20px; height: 20px; }
.date-wrap .date-button:hover { color: var(--blue) !important; }
.date-wrap .date-picker { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px;
                          opacity: 0; pointer-events: none; border: 0; padding: 0; }
main .smalltext { font-size: .9em; line-height: 1.3em; }
.content { margin: 0; overflow-x: auto; }   /* wide tables scroll here, not the page */
.cards a.card h3 { margin: 0 0 .35rem; }

/* Name and reporting year under the heading of the report pages */
dl.report-ident { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .6rem; margin: 0 0 1rem; }
dl.report-ident dt { color: var(--muted); }
dl.report-ident dd { margin: 0; font-weight: bold; }

/* Notes in the page (e.g. at a button: why it is disabled) */
main .note { padding: .45rem .8rem; border-radius: var(--radius); border-left: 5px solid; margin: 0 0 .8rem; }
main .note.warning { background: #fdf5e1; border-color: var(--gold); color: #6b4d00; }
main .note.info { background: #eef3f9; border-color: var(--navy); color: var(--navy); }
/* The submit area of Review and Submit */
.submit-box { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin: 1rem 0; }
.submit-box .consent { display: block; margin-bottom: .8rem; }
.submit-box .consent:has(input:disabled) { color: #9a9aa3; }
main .submit-box button.primary { background: var(--navy); color: var(--white); border: 1px solid var(--navy);
                                  border-radius: 4px; padding: .45rem 1.4rem; font: inherit; cursor: pointer; }
main .submit-box button.primary:disabled { background: #c9ccd3; border-color: #c9ccd3; color: #f5f5f7; cursor: default; }

/* ── Lists of items (lib/includes/report_list.php, js/list.js) ─────────── */
.list-item { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 .8rem; background: var(--white); }
.list-item .item-bar { display: flex; align-items: center; gap: .5rem; background: #f2f3f6;
                       border-bottom: 1px solid var(--line); padding: .3rem .5rem;
                       border-radius: var(--radius) var(--radius) 0 0; }
.list-item .drag { cursor: grab; color: var(--muted); font-size: 1.1rem; padding: 0 .2rem; user-select: none; }
.list-item .item-title { flex: 1; min-width: 0; font-weight: bold; color: var(--navy);
                         overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .item-title em { font-weight: normal; color: var(--muted); }
.list-item .item-buttons { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
main .list-item .item-buttons button { font: inherit; font-size: .8rem; padding: .15rem .55rem; border-radius: 4px;
                                       border: 1px solid var(--line); background: var(--white); color: var(--navy); }
main .list-item .item-buttons button:hover { background: #e8edf4; }
main .list-item .item-buttons button.delete { color: var(--red); }
.list-item .item-buttons .undo, .list-item .deleted-note { display: none; }
.list-item.deleted .item-buttons button { display: none; }
.list-item.deleted .item-buttons .undo { display: inline-block; }
.list-item.deleted .item-fields { opacity: .45; }
.list-item.deleted .item-title { text-decoration: line-through; color: var(--muted); }
.list-item.deleted .deleted-note { display: block; padding: 0 .9rem .6rem; color: var(--red); font-size: .85rem; }
.list-item.dragging { opacity: .5; }
.list-item .item-fields { padding: .6rem .9rem; display: grid; grid-template-columns: max-content 1fr; gap: .4rem .8rem; }
.list-item .field { display: contents; }
.list-item .field > label { text-align: right; padding-top: .3rem; }
.list-item .field .help { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.list-item .req { color: var(--red); }
main button.add-item { font: inherit; border: 1px dashed var(--navy); background: var(--white); color: var(--navy);
                       border-radius: var(--radius); padding: .45rem 1rem; cursor: pointer; }
main button.add-item:hover { background: #e8edf4; }
@media (max-width: 640px) {
  .list-item .item-fields { grid-template-columns: 1fr; gap: .15rem; }
  .list-item .field > label { text-align: left; padding-top: .4rem; }
}

/* ── Comments and approval on the report views (lib/includes/comments.php) ─ */
.comment-received { border-left: 4px solid var(--navy); background: #f4f6fa; border-radius: var(--radius);
                    padding: .5rem .9rem; margin: 0 0 .9rem; }
.comment-received h4 { margin: 0 0 .3rem; font-size: .95rem; }
.comment-received .when { font-weight: normal; color: var(--muted); font-size: .85rem; margin-left: .4rem; }
.comment-help { color: var(--muted); font-size: .9rem; }
.comment-box { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; margin: 0 0 .9rem; }
.comment-box h4 { margin: 0 0 .4rem; }
.comment-box .comment-foot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .4rem; }
.comment-box .comment-status { flex: 1; font-size: .85rem; }
.comment-status .draft { color: #8a6100; }
.comment-status .sent { color: var(--green); }
main .comment-box button.send, main button.save, main .approve-box button {
  font: inherit; border-radius: 4px; padding: .35rem .9rem; cursor: pointer;
  border: 1px solid var(--navy); background: var(--white); color: var(--navy); }
main .comment-box button.send { background: var(--navy); color: var(--white); }
main .approve-box button.primary { background: var(--navy); color: var(--white); }
main .approve-box button:disabled { background: #c9ccd3; border-color: #c9ccd3; color: #f5f5f7; cursor: default; }
.approve-box { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 1.2rem 0; }

/* Filter forms above lists (reporting year, sort order) */
form.filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem;
              background: #f2f3f6; border: 1px solid var(--line); border-radius: var(--radius);
              padding: .6rem .9rem; margin: 0 0 1rem; }

/* ── Action bar of the report pages: Back, Save, Cancel, Next ───────────────
   Back and Next are light; the names of their sections shrink, and go when
   the bar is narrow (a container query: the bar's own width counts). */
.action-bar { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: .5rem;
              background: var(--white); border-bottom: 1px solid var(--line);
              padding: .45rem 0; margin-bottom: 1rem; container-type: inline-size; }
.action-bar .middle { flex: none; display: flex; justify-content: center; gap: .5rem; margin: 0 auto; }
main .action-bar button, main a.button {
  font: inherit; border-radius: 4px; padding: .35rem .9rem; cursor: pointer; text-decoration: none;
  border: 1px solid var(--navy); background: var(--white); color: var(--navy); line-height: 1.3; }
main .action-bar button.primary { background: var(--navy); color: var(--white); padding: .35rem 1.4rem; }
main .action-bar button:hover, main a.button:hover { background: #e8edf4; }
main .action-bar button.primary:hover { background: var(--blue); }
main a.button[aria-disabled] { border-color: var(--line); color: #9a9aa3; cursor: default; background: var(--white); }
main .action-bar .nav { flex: 0 1 auto; min-width: 0; border: 1px solid transparent; border-radius: 4px;
                        background: none; color: var(--navy); text-decoration: none; line-height: 1.3;
                        padding: .3rem .5rem; text-align: left; cursor: pointer; }
main .action-bar .nav:hover { background: #e8edf4; }
main .action-bar .nav:last-child { text-align: right; }
.action-bar .nav .target { display: block; font-size: .72rem; color: var(--muted);
                           overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@container (max-width: 34rem) {
  .action-bar .nav .target { display: none; }
}

/* ── Dialog for an action that failed ──────────────────────────────────── */
dialog.problem-dialog { border: none; border-top: 5px solid var(--red); border-radius: var(--radius);
                        padding: 1.2rem 1.4rem 1rem; max-width: min(30rem, 90vw);
                        box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
dialog.problem-dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog.problem-dialog h2 { margin: 0 0 .5rem; color: var(--red); font-size: 1.2rem; font-weight: bold; }
dialog.problem-dialog p { margin: 0 0 1rem; }
dialog.problem-dialog .buttons { text-align: right; }
dialog.problem-dialog button, dialog.confirm-dialog button {
  font: inherit; background: var(--navy); color: var(--white); border: 1px solid var(--navy);
  border-radius: 4px; padding: .4rem 1.2rem; cursor: pointer; }
dialog.confirm-dialog button.secondary { background: var(--white); color: var(--navy); }
dialog.leave-dialog ul { margin: 0 0 1rem; padding-left: 1.2rem; }
dialog.leave-dialog .buttons { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
dialog.leave-dialog a.button { font: inherit; border: 1px solid var(--navy); border-radius: 4px; padding: .4rem 1rem;
                               color: var(--navy); text-decoration: none; background: var(--white); }
dialog.confirm-dialog { border: none; border-top: 5px solid var(--navy); border-radius: var(--radius);
                        padding: 1.2rem 1.4rem 1rem; max-width: min(26rem, 90vw);
                        box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }
dialog.confirm-dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog.confirm-dialog p { margin: 0 0 1rem; }
dialog.confirm-dialog .buttons { text-align: right; }

/* ── "More below" (frame.php): shown while content is below the window ── */
.more-below { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%) translateY(8px);
              width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer; z-index: 30;
              background: rgba(0, 51, 102, .85); color: var(--white); box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
              display: flex; align-items: center; justify-content: center;
              opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.more-below.shown { opacity: 1; pointer-events: auto; transform: translateX(-50%); }
.more-below:hover { background: var(--navy); }
.more-below svg { width: 24px; height: 24px; }
@media print { .more-below { display: none; } }

/* ── Overlay sheet (e.g. the report review) and pages shown in one ────── */
dialog.sheet { width: min(60rem, 94vw); height: 90vh; max-height: 90vh; padding: 0; border: none;
               border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0, 0, 0, .4); overflow: hidden; }
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .55); }
dialog.sheet .sheet-head { display: flex; align-items: center; gap: 1rem; background: var(--navy); color: var(--white);
                           padding: .5rem .6rem .5rem 1.1rem; }
dialog.sheet .sheet-head h2 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: normal; color: var(--white); }
dialog.sheet .close { font: inherit; font-size: 1.6rem; line-height: 1; background: none; border: none;
                      color: var(--white); cursor: pointer; padding: .1rem .5rem; border-radius: 4px; }
dialog.sheet .close:hover { background: rgba(255, 255, 255, .15); }
dialog.sheet iframe { flex: 1; width: 100%; border: none; }
body.bare { background: var(--white); }
body.bare main { padding: 1rem 1.25rem; }

/* ── Report sections (sidebar on report pages) ───────────────────────────
   A column beside the page (.report-main) that stays in place while the
   page scrolls, scrolling on its own if the window is too short. */
main:has(> .sidebar) { display: flex; align-items: flex-start; gap: 1.5rem; }
.report-main { flex: 1; min-width: 0; }
.sidebar { flex: none; width: 15rem; position: sticky; top: .5rem;
           max-height: calc(100vh - 1rem); overflow-y: auto; }
.sidebar summary { display: none; }
.sidebar ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line);
              border-radius: var(--radius); overflow: hidden; }
.sidebar li + li { border-top: 1px solid var(--line); }
.sidebar a { display: block; padding: .3rem .65rem; text-decoration: none; color: var(--text);
             font-size: .8rem; line-height: 1.25; border-left: 4px solid transparent; }
.sidebar a:hover { background: #f2f3f6; }
.sidebar a.on { background: var(--grey); border-left-color: var(--navy); font-weight: bold; color: var(--navy); }

/* ── Footer ────────────────────────────────────────────────────────────── */
.site-footer { background: var(--green); color: var(--white); font-size: .8rem;
               padding: .55rem 1.25rem; display: flex; flex-wrap: wrap; gap: .3rem 1rem;
               justify-content: space-between; }
.site-footer a { color: var(--white); }
.site-footer .revision { opacity: .85; }

/* ── Phones ────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .frame { width: auto; }   /* phones: no ochre margins */
  .site-header { padding: .5rem .75rem; gap: .5rem; }
  .site-header .logo img { height: 34px; }
  .site-header .title .faculty { font-size: .8rem; }
  .site-header .title .site { font-size: 1.05rem; }
  .header-actions .label { display: none; }      /* icons only */
  .header-actions a, .user-menu > summary { padding: .4rem; }
  main { padding: 1rem .75rem 1.5rem; }
  main h1 { font-size: 1.4rem; }
  .status { padding: .5rem .75rem 0; }
  .section-bar { flex-wrap: wrap; }
  .section-bar a { padding: .55rem .7rem; font-size: .8rem; letter-spacing: 0; }
  main h2 { font-size: 1.35rem; }
  .action-bar { gap: .3rem; }
  main .action-bar button, main a.button { padding: .35rem .6rem; }
  main .action-bar button.primary { padding: .35rem .9rem; }
  main:has(> .sidebar) { display: block; }
  .sidebar { width: auto; margin: 0 0 1rem; position: static; max-height: none; }
  .sidebar summary { display: block; cursor: pointer; padding: .55rem .75rem; background: #f2f3f6;
                     border: 1px solid var(--line); border-radius: var(--radius); color: var(--navy); }
  .sidebar summary span { font-weight: bold; }
  .sidebar details[open] summary { border-radius: var(--radius) var(--radius) 0 0; }
  .sidebar details[open] ul { border-top: none; border-radius: 0 0 var(--radius) var(--radius); }
}

/* ── Printing ──────────────────────────────────────────────────────────── */
@media print {
  body { background: var(--white); }
  .frame { width: auto; }
  .site-header { position: static; background: var(--white); color: var(--black); }
  .site-header .title, .site-header .title .faculty { color: var(--black); }
  .site-header .logo, .header-actions, .section-bar, .sidebar, .filter, .action-bar, .site-footer { display: none; }
}
