.resource-access {
  min-height: min(65vh, 660px);
  display: grid;
  place-items: center;
}
.resource-access__card {
  width: min(100%, 540px);
  padding: clamp(24px, 5vw, 40px);
  text-align: center;
}
.resource-access__card h1 { margin: 0; color: var(--r2-color-navy-900); }
.resource-access__card p { line-height: 1.6; color: var(--r2-color-muted); }
.resource-access__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.resource-library__group + .resource-library__group { margin-top: 12px; }
.resource-library__group > summary {
  cursor: pointer;
  padding: 15px 18px;
  color: var(--r2-color-navy-900);
  font-weight: 750;
}
.resource-library__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--r2-color-line);
}
.resource-library__row h3 { margin: 0; font-size: .9rem; color: var(--r2-color-navy-900); }

.resource-edition { padding: 24px; }
.resource-edition h2 { margin: 0; color: var(--r2-color-navy-900); }
.resource-edition h2:focus { outline: none; box-shadow: none; }
.resource-edition [data-resource-edition-close] { display: flex; margin-inline-start: auto; }
.resource-edition p { color: var(--r2-color-muted); }
.resource-edition__choices { display: grid; gap: 8px; margin-bottom: 16px; }
.resource-edition__button.r2-button {
  display: grid;
  justify-content: start;
  text-align: left;
  border-inline-start: 4px solid var(--challenge-colour, var(--r2-color-line));
  gap: 2px;
}
.resource-edition__button small { color: var(--r2-color-muted); font-weight: 500; }
.resource-edition__button[data-category="SENIOR"] { --challenge-colour: #b93e38; }
.resource-edition__button[data-category="INTERMEDIATE"] { --challenge-colour: #287b59; }
.resource-edition__button[data-category="JUNIOR"] { --challenge-colour: #a9500f; }
.resource-edition__button[data-category="PRIMARY"] { --challenge-colour: #087d98; }

/* Move visual focus to interactive controls instead of framing the dialog or title. */
body[data-page="resources"] :is(.resource-preview-dialog, .resource-customisation-dialog):focus {
  outline: none;
  box-shadow: 0 24px 70px rgb(7 29 51 / 28%);
}
.resource-preview [data-resource-preview-title]:focus {
  outline: none;
  box-shadow: none;
}
body[data-page="resources"] :is([data-resource-library], .resource-preview-dialog, .resource-customisation-dialog) :is(button, input, summary):focus-visible {
  outline: 2px solid #1466be;
  outline-offset: 2px;
  box-shadow: none;
}

.resource-customisation-fields label {
  min-width: 0;
}

.resource-edition__choices {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.resource-edition__button.r2-button {
  align-content: center;
  min-width: 0;
}

@media screen and (min-width: 601px) {
  .resource-customisation-fields {
    row-gap: 8px;
  }
  .resource-customisation-fields label {
    grid-row: span 3;
    grid-template-rows: subgrid;
  }
  .resource-customisation-fields label:nth-child(n + 3) {
    margin-top: 8px;
  }
}

.resource-preview__heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
}
.resource-preview__heading h1 {
  margin-bottom: 0;
}
.resource-preview__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.resource-preview__actions svg {
  flex: none;
  width: 1.1em;
  height: 1.1em;
}

@media screen and (max-width: 460px) {
  .resource-edition { padding: 0; }
  .resource-edition__choices { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  .resource-preview__actions,
  .resource-preview__close { display: none !important; }
  .resource-preview__heading { display: block; }
}

/* The page can receive programmatic focus after a dialog closes. */
body[data-page="resources"] #organiser-main:focus {
  outline: none;
  box-shadow: none;
}
.resource-preview [data-resource-preview-body][data-resource-id="student-instructions"] {
  gap: 8px;
}
.resource-preview [data-resource-id="student-instructions"] > :is(p, ul, ol) {
  margin: 0;
}

.resource-document-status {
  color: var(--r2-color-muted);
  margin: 16px 0 0;
}
.resource-preview .resource-preview__list {
  margin: 0;
  padding-inline-start: 1.5em;
}
.resource-preview__list > li + li { margin-top: 4px; }
.resource-document-status.is-busy::before,
[data-resource-download].is-busy::before {
  content: '';
  display: inline-block;
  width: .85em;
  height: .85em;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: resource-loading-spin .75s linear infinite;
}
.resource-document-status.is-busy::before { margin-inline-end: .6em; }
[data-resource-download].is-busy svg { display: none; }
@keyframes resource-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .resource-document-status.is-busy::before,
  [data-resource-download].is-busy::before { animation: none; }
}

.resource-preview__heading {
  padding: clamp(14px, 3vw, 24px);
  border-radius: 12px;
  background: #102a43;
  color: #fff;
}
.resource-preview__heading h1 { color: inherit; margin: 0; }
.resource-preview__caption { margin: 8px 0 0; color: #e0ebf5; line-height: 1.5; }
.resource-preview [data-resource-id="challenge-day-checklist"] { gap: 8px; padding-block-start: 12px; }
.resource-preview [data-resource-id="challenge-day-checklist"] .resource-preview__checklist { gap: 4px; }
.resource-preview [data-resource-id="challenge-day-checklist"] > p { margin: 0; }

/* File-explorer library. Previews are decorative; each whole tile is one keyboard control. */
.resource-explorer-toolbar{display:flex;align-items:center;gap:16px;margin:2px 0 22px;padding:12px 14px;border:1px solid #dce5ed;border-radius:13px;background:#fff}
.resource-explorer-search{display:flex;align-items:center;gap:9px;flex:1;min-width:0;max-width:420px;color:#6a7f92}
.resource-explorer-search svg{width:20px;height:20px;flex-shrink:0}
.resource-explorer-search input{width:100%;min-width:0;border:0;background:transparent;color:#0b2a4a;font:inherit;font-size:.9rem;outline:none;padding:5px 0}
.resource-explorer-search:focus-within{outline:2px solid #1466be;outline-offset:5px;border-radius:3px}
.resource-explorer-count{margin-left:auto;white-space:nowrap;color:#6a7f92;font-size:.8rem}
.resource-explorer-views{display:flex;gap:3px;padding:3px;border-radius:8px;background:#eef3f7}
.resource-explorer-views button{display:flex;justify-content:center;align-items:center;width:34px;height:32px;padding:7px;border:0;border-radius:6px;background:transparent;color:#637c91;cursor:pointer}
.resource-explorer-views svg{width:20px;height:20px}
.resource-explorer-views button[aria-pressed="true"]{background:#fff;color:#0b2a4a;box-shadow:0 1px 4px #0b2a4a1a}
.resource-library__group.r2-card{background:transparent;border:0;box-shadow:none;border-radius:0;overflow:visible}
.resource-library__group+.resource-library__group{margin-top:26px}
.resource-library__group[hidden],.resource-file[hidden]{display:none!important}
.resource-library__group>summary{display:flex;align-items:center;gap:9px;list-style:none;padding:0 0 12px;border-bottom:1px solid #dce5ed;font-size:.9rem;font-weight:750;cursor:pointer}
.resource-library__group>summary::-webkit-details-marker{display:none}
.resource-library__group>summary::before{content:"";width:7px;height:7px;flex-shrink:0;border-right:1.5px solid #8b9eaf;border-bottom:1.5px solid #8b9eaf;transform:rotate(-45deg);transition:transform .15s}
.resource-library__group[open]>summary::before{transform:rotate(45deg);margin-top:-4px}
.resource-library__folder{display:flex;color:#5885b1}
.resource-library__folder svg{width:23px;height:23px}
.resource-library__count{margin-left:1px;min-width:22px;padding:1px 6px;border-radius:5px;background:#e5edf5;color:#637b90;text-align:center;font-size:.72rem;font-weight:650}
.resource-library__files{display:grid;grid-template-columns:repeat(auto-fill,minmax(178px,1fr));gap:16px 12px;padding:16px 0 0}
.resource-library__row.resource-file{display:block;min-width:0;padding:0;border:0}
.resource-file__open{display:flex;flex-direction:column;align-items:stretch;width:100%;height:100%;min-width:0;padding:10px 10px 13px;border:1px solid transparent;border-radius:13px;background:transparent;color:#0b2a4a;font:inherit;text-align:center;cursor:pointer;transition:background .15s,border-color .15s}
.resource-file__open:hover{background:#e7f0fa;border-color:#d0dfef}
.resource-file__open:focus-visible{outline:2px solid #1466be!important;outline-offset:2px!important;background:#e7f0fa}
.resource-file__open:disabled{cursor:progress;opacity:.65}
.resource-file__preview{position:relative;display:flex;align-items:flex-start;justify-content:center;height:195px;margin-bottom:13px;padding-top:4px;overflow:hidden;border-radius:6px;background:transparent}
.resource-file__paper{position:relative;display:block;box-sizing:border-box;width:148px;height:190px;flex:0 0 148px;padding:13px 12px;background:#fff;border:1px solid #d8e2eb;border-radius:3px;box-shadow:0 3px 6px #16375212,0 9px 16px #16375208;text-align:left;overflow:hidden;pointer-events:none}
.resource-file__paper::after{position:absolute;content:"";left:0;right:0;bottom:0;height:13px;background:linear-gradient(transparent,#fff)}
.resource-file__brand{display:flex;align-items:center;gap:4px;margin-bottom:7px;border-bottom:1px solid #dae3ed;padding-bottom:6px}
.resource-file__brand img{width:15px;height:15px;object-fit:contain}
.resource-file__brand-name{font-size:6px;font-weight:800;letter-spacing:.8px;color:#0b2a4a}
.resource-file__document-title{display:block;margin:0 0 7px;font-size:8px;font-weight:800;line-height:1.2;color:#0b2a4a}
.resource-file__document-copy{display:block;margin:0 0 5px;font-size:5px;line-height:1.45;font-weight:400;color:#536576;overflow-wrap:anywhere}
.resource-file__document-heading{display:block;margin:7px 0 4px;font-size:5.5px;line-height:1.3;font-weight:800;color:#0b2a4a}
.resource-file__document-list{display:block;margin:0 0 5px;color:#536576;font-size:5px;line-height:1.4}
.resource-file__document-list>span{display:block;margin:2px 0}
.resource-file__document-table{display:grid;grid-template-columns:repeat(var(--preview-columns,2),minmax(0,1fr));margin:4px 0;border-top:1px solid #e0e7ed;border-left:1px solid #e0e7ed}
.resource-file__document-cell{padding:3px;font-size:4.5px;line-height:1.35;overflow:hidden;max-height:40px;border-bottom:1px solid #e0e7ed;border-right:1px solid #e0e7ed;color:#536576}
.resource-file__document-cell.is-header{background:#eaf1f7;color:#0b2a4a;font-weight:800}
.resource-file__document-callout{display:block;padding:4px;background:#edf5fc;border-left:2px solid #8ab6dd}
.resource-file__document-callout .resource-file__document-heading{margin-top:0}
.resource-file__cover-note{display:block;margin-top:16px;font-size:6px;color:#7c8d9c}
.resource-file__format{position:absolute;left:calc(50% - 81px);bottom:5px;padding:3px 7px;border-radius:4px;background:#f8eeee;border:1px solid #ead3d3;color:#a54e4e;font-size:.57rem;line-height:1.1;letter-spacing:.04em;font-weight:800}
.resource-file__name{display:block;max-width:220px;align-self:center;font-size:.87rem;line-height:1.35;font-weight:700;overflow-wrap:anywhere}
.resource-file__purpose{display:block;max-width:225px;align-self:center;margin-top:5px;color:#61778a;font-size:.75rem;line-height:1.45;font-weight:400}
.resource-explorer-empty{padding:32px 16px;border:1px dashed #ccd8e3;border-radius:12px;text-align:center;color:#61778a}
[data-view="list"] .resource-library__files{grid-template-columns:minmax(0,1fr);gap:4px;padding-top:8px}
[data-view="list"] .resource-file__open{display:grid;grid-template-columns:48px minmax(0,1fr);column-gap:16px;text-align:left;padding:9px 14px}
[data-view="list"] .resource-file__preview{grid-row:span 2;height:55px;margin:0;padding:0;width:43px;overflow:visible}
[data-view="list"] .resource-file__paper{width:39px;height:51px;flex-basis:39px;padding:4px}
[data-view="list"] .resource-file__brand{display:none}
[data-view="list"] .resource-file__document-title{font-size:3px;margin:0 0 3px}
[data-view="list"] .resource-file__document-copy{font-size:1.5px;line-height:1.2}
[data-view="list"] .resource-file__document-heading{font-size:2px;margin:2px 0}
[data-view="list"] .resource-file__format{left:0;bottom:0;font-size:.36rem;padding:2px 3px}
[data-view="list"] .resource-file__name{align-self:end;justify-self:start;max-width:none}
[data-view="list"] .resource-file__purpose{align-self:start;justify-self:start;max-width:none;margin-top:2px}
@media(max-width:600px){.resource-explorer-toolbar{flex-wrap:wrap;gap:10px;padding:10px}.resource-explorer-search{flex-basis:calc(100% - 96px);max-width:none}.resource-explorer-count{order:3;width:100%;margin:0 0 0 29px;font-size:.75rem}.resource-explorer-views{margin-left:auto}.resource-library__files{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 4px}.resource-file__open{padding:8px 5px 12px}.resource-file__preview{height:164px}.resource-file__paper{width:121px;height:158px;flex-basis:121px;padding:10px}.resource-file__format{left:calc(50% - 65px);bottom:2px}.resource-file__name{font-size:.8rem}.resource-file__purpose{font-size:.72rem}.resource-file__document-title{font-size:7px}.resource-file__document-copy{font-size:4.4px}.resource-file__document-heading{font-size:5px}.resource-library__group+.resource-library__group{margin-top:20px}}
@media(prefers-reduced-motion:reduce){.resource-file__open,.resource-library__group>summary::before{transition:none}}
