:root {
  --navy: #0f1e35;
  --ink: #13233f;
  --paper: #f9f4ee;
  --gold: #c4a06a;
  --gold-dark: #7d5f2d;
  --muted: #5d5a55;
  --serif: "Source Serif 4", Georgia, serif;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
[hidden] {
  display: none !important;
}
body {
  font: 1.0625rem/1.65 var(--serif);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img {
  display: block;
  max-width: 100%;
  height: auto;
}
a {
  color: inherit;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.wrap {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding-inline: clamp(1rem, 4.5vw, 4.5rem);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

/* Zaglavlje */
.site-header {
  background: var(--navy);
  color: #fff;
}
.bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 2rem;
  position: relative;
  padding-block: 0.6rem;
}
.bar::after {
  content: "";
  position: absolute;
  left: clamp(1rem, 2.6vw, 2.6rem);
  right: clamp(1rem, 2.6vw, 2.6rem);
  bottom: 0;
  height: 2px;
  background: #fff;
}
.logo img {
  width: clamp(200px, 20vw, 270px);
}
nav {
  display: flex;
}
nav a {
  text-decoration: none;
  font-size: clamp(1.05rem, 1.7vw, 1.65rem);
  padding: 0.15rem clamp(0.8rem, 2.2vw, 2.2rem);
  border-left: 2px solid #fff;
}
nav a:first-child {
  border-left: 0;
  padding-left: 0;
}
nav a:last-child {
  padding-right: 0;
}
nav a:hover,
nav a[aria-current] {
  color: #e2c08d;
}

/* Naslovni dio */
.hero {
  color: #fff;
  background: var(--navy) url("img/plavi-kolaz.webp") right center / cover
    no-repeat;
}
.hero .wrap {
  padding-block: clamp(2.5rem, 6vw, 5.5rem) clamp(1.5rem, 3vw, 2.5rem);
}
.hero h1 {
  font:
    700 clamp(2.7rem, 5.4vw, 5.4rem) / 1.1 Oswald,
    "Arial Narrow",
    sans-serif;
  text-transform: uppercase;
}
.hero p {
  font-size: clamp(1.15rem, 2.4vw, 2.2rem);
  margin-block: 0.5rem 1.8rem;
}
.search {
  display: flex;
  gap: 0.75rem;
  max-width: 810px;
}
.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--paper);
  border-radius: 8px;
  padding-inline: 1.4rem;
  color: var(--muted);
}
.search-field:focus-within {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}
.search-field svg {
  width: 1.9rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: none;
  outline: 0;
  padding-block: 0.9rem;
  font-size: clamp(1rem, 1.8vw, 1.6rem);
}
.search button {
  background: var(--gold);
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  font-weight: 600;
  font-size: clamp(1rem, 1.8vw, 1.6rem);
  padding: 0 clamp(1rem, 2.6vw, 2.4rem);
}
.search button:hover {
  background: #d3b27f;
}

/* Sadržaj */
main {
  flex: 1;
  padding-block: 1.75rem 3.5rem;
}
.view {
  display: none;
}
.view.active {
  display: block;
}
#zbirke {
  scroll-margin-top: 1rem;
}
.title {
  font-size: clamp(2.1rem, 4vw, 3.4rem);
  line-height: 1.25;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.3rem;
  margin-bottom: 1.4rem;
}
.lead {
  color: var(--muted);
  max-width: 70ch;
  margin-bottom: 1.5rem;
}

.collections {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  row-gap: 1.5rem;
}
.collections li {
  flex: 1 1 auto;
  display: flex;
  border-left: 1px solid var(--gold);
}
.collections li:first-child {
  border-left: 0;
}
.collections a {
  flex: 1;
  text-decoration: none;
  text-align: center;
  padding: 0.25rem 1.5rem;
}
.collections li:first-child a {
  text-align: left;
  padding-left: 1rem;
}
.collections strong {
  display: block;
  font-size: clamp(1.3rem, 2.2vw, 2rem);
  line-height: 1.4;
}
.collections small {
  display: block;
  color: var(--muted);
  font-size: 1.1rem;
}
.collections a:hover strong {
  color: var(--gold-dark);
  text-decoration: underline;
  text-underline-offset: 6px;
}

.featured {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2.5rem;
  margin-block: 3rem;
}
.card-btn {
  border: 0;
  background: none;
  padding: 0;
  display: block;
  width: 100%;
}
.card-btn img {
  width: 100%;
  border: 6px solid #fffdf8;
  box-shadow: 0 3px 14px rgba(15, 30, 53, 0.22);
}
.featured > .card-btn {
  width: min(100%, 420px);
}
.featured-text {
  border-left: 1px solid var(--gold);
  padding: 1rem 0 1rem 2.5rem;
  font-size: 1.6rem;
}
.featured-text h3 {
  font-size: clamp(2rem, 3.4vw, 2.8rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.3;
  margin-bottom: 0.8rem;
}
.link {
  background: none;
  border: 0;
  border-bottom: 2px solid var(--gold);
  font-size: 1.4rem;
}
.link:hover {
  color: var(--gold-dark);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  gap: 1.5rem;
  border-top: 1px solid var(--gold);
  padding-top: 1.5rem;
  text-align: center;
}
.stats div {
  display: flex;
  flex-direction: column-reverse;
}
.stats dd {
  font-size: 2.2rem;
  font-weight: 600;
}
.stats dt {
  color: var(--muted);
}

/* Čitaonica */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  margin-bottom: 1.5rem;
}
.tabs a {
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tabs a:hover {
  color: var(--gold-dark);
}
.tabs a[aria-current] {
  border-color: var(--gold);
}
.reader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 2.5rem;
  align-items: start;
}
.directory {
  max-height: 34rem;
  overflow-y: auto;
  border-block: 1px solid var(--gold);
}
.directory button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid #e4d9c8;
  padding: 0.7rem 0.8rem;
  overflow-wrap: anywhere;
}
.directory button:hover {
  background: #efe6d8;
}
.directory button.selected {
  background: var(--navy);
  color: #fff;
}
.directory p {
  padding: 0.7rem 0.8rem;
  color: var(--muted);
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
}
.controls label {
  flex: 1 1 9rem;
  min-width: 0;
  font-size: 0.95rem;
  color: var(--muted);
}
.controls label:first-child {
  flex-basis: 14rem;
}
.controls select {
  display: block;
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cdbd9f;
  border-radius: 6px;
  padding: 0.65rem 0.7rem;
}
.controls button {
  background: var(--gold);
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  padding: 0.72rem 1.4rem;
}
.info {
  margin-top: 2rem;
  max-width: 72ch;
}
.info h3 {
  font-size: 1.6rem;
  line-height: 1.3;
  margin-bottom: 0.8rem;
}
.info p {
  margin-bottom: 0.9rem;
}
.notice {
  border-left: 3px solid var(--gold);
  padding: 0.5rem 1rem;
}

.results {
  list-style: none;
  max-width: 80ch;
}
.results li {
  border-bottom: 1px solid #e4d9c8;
}
.results a {
  display: block;
  text-decoration: none;
  padding: 0.8rem 0;
  overflow-wrap: anywhere;
}
.results a:hover strong {
  color: var(--gold-dark);
  text-decoration: underline;
}
.results strong {
  display: block;
  font-size: 1.25rem;
}
.results span {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Razglednice i tekstualne stranice */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 2rem;
  align-items: start;
}
figcaption {
  font-style: italic;
  margin-top: 0.6rem;
}
.article {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 3rem;
  align-items: start;
}
.article > div {
  max-width: 70ch;
}
.article h3 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 1.8rem 0 0.6rem;
}
.article h3:first-child {
  margin-top: 0;
}
.article p,
.article ul {
  margin-bottom: 1rem;
}
.article ul {
  padding-left: 1.3rem;
}
.article figure img {
  border: 6px solid #fffdf8;
  box-shadow: 0 3px 14px rgba(15, 30, 53, 0.22);
}

dialog {
  margin: auto;
  border: 0;
  background: var(--paper);
  padding: 0.8rem;
  max-width: min(96vw, 1360px);
}
dialog::backdrop {
  background: rgba(8, 16, 30, 0.85);
}
dialog img {
  max-height: 80vh;
  width: auto;
}
dialog form {
  text-align: right;
  margin-top: 0.6rem;
}
dialog button {
  background: var(--gold);
  border: 0;
  border-radius: 6px;
  padding: 0.4rem 1.2rem;
}

footer {
  background: var(--navy);
  color: #d7dbe4;
  padding-block: 1.5rem;
  font-size: 0.95rem;
}

@media (max-width: 1100px) {
  .collections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }
  .collections li,
  .collections li:first-child {
    border-left: 3px solid var(--gold);
  }
  .collections a,
  .collections li:first-child a {
    text-align: left;
    padding: 0.25rem 1rem;
  }
}
@media (max-width: 800px) {
  .hero {
    background-image:
      linear-gradient(rgba(15, 30, 53, 0.65), rgba(15, 30, 53, 0.65)),
      url("img/plavi-kolaz.webp");
  }
  .reader,
  .article {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
  .directory {
    max-height: 16rem;
  }
  .featured-text {
    border-left: 0;
    padding: 0;
    width: 100%;
    max-width: 420px;
  }
}
@media (max-width: 520px) {
  .search {
    flex-direction: column;
  }
  .search button {
    padding-block: 0.7rem;
  }
}

/* ---------- Prilagodba uređajima ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  min-height: 100dvh;
  overflow-wrap: break-word;
}
/* Najmanje 16px sprječava automatsko zumiranje na iPhoneu */
.controls select {
  font-size: 1rem;
}
dialog img {
  max-height: calc(100vh - 6rem);
  max-height: calc(100dvh - 6rem);
  max-width: 100%;
  margin-inline: auto;
}

/* Veliki monitori */
@media (min-width: 1900px) {
  html {
    font-size: 112.5%;
  }
  .wrap {
    max-width: 1800px;
  }
}

/* Tableti */
@media (min-width: 521px) and (max-width: 1100px) {
  .featured {
    flex-wrap: nowrap;
    gap: 1.5rem;
  }
  .featured > .card-btn {
    flex: 1 1 55%;
    width: auto;
    min-width: 0;
  }
  .featured-text {
    flex: 1 1 45%;
    width: auto;
    border-left: 1px solid var(--gold);
    padding: 0.5rem 0 0.5rem 1.5rem;
  }
}

/* Mobiteli */
@media (max-width: 600px) {
  .logo {
    margin-inline: auto;
  }
  nav {
    width: 100%;
  }
  nav a {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding-inline: 0.4rem;
  }
  nav a:first-child,
  nav a:last-child {
    padding-inline: 0.4rem;
  }
  .collections {
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem 0.75rem;
  }
  .collections li:first-child {
    grid-column: 1 / -1;
  }
  .collections a,
  .collections li:first-child a {
    min-height: 44px;
    padding-inline: 0.75rem;
  }
  .collections strong {
    font-size: 1.2rem;
  }
  .featured {
    margin-block: 2rem;
    gap: 1rem;
  }
  .featured-text {
    font-size: 1.25rem;
  }
  .stats {
    flex-direction: column;
    gap: 0;
    text-align: left;
  }
  .stats div {
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding-block: 0.35rem;
  }
  .stats dd {
    font-size: 1.4rem;
    white-space: nowrap;
  }
  .tabs {
    gap: 0.25rem 1.25rem;
  }
  .tabs a {
    font-size: 1.15rem;
    padding-block: 0.4rem;
  }
  .controls label,
  .controls label:first-child {
    flex-basis: 100%;
  }
  .controls button {
    width: 100%;
    min-height: 48px;
  }
}

/* Vrlo uski ekrani */
@media (max-width: 359px) {
  nav a {
    font-size: 0.95rem;
  }
  .collections {
    grid-template-columns: 1fr;
  }
}

/* Položeni mobitel */
@media (max-height: 500px) and (orientation: landscape) {
  .hero .wrap {
    padding-block: 1.25rem;
  }
  .hero h1 {
    font-size: 2.5rem;
  }
  .hero p {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
  }
  .directory {
    max-height: 70dvh;
  }
}

/* Dodirni zasloni: veće površine za dodir */
@media (pointer: coarse) {
  .link,
  .tabs a,
  dialog button {
    min-height: 44px;
  }
  .tabs a {
    display: inline-flex;
    align-items: center;
  }
  footer a {
    display: inline-block;
    padding-block: 0.4rem;
  }
}

@media print {
  .site-header nav,
  .hero,
  .controls,
  .directory,
  footer {
    display: none !important;
  }
}

/* Zbirke na tabletima: tri u prvom redu, dvije u drugom */
@media (min-width: 601px) and (max-width: 1100px) {
  .collections {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .collections li {
    grid-column: span 2;
  }
  .collections li:nth-child(n + 4) {
    grid-column: span 3;
  }
}
@media (min-width: 801px) and (max-width: 1100px) {
  .controls button {
    flex: 1 1 100%;
  }
}
@media (max-width: 359px) {
  .search-field {
    gap: 0.5rem;
    padding-inline: 0.7rem;
  }
  .search-field svg {
    width: 1.3rem;
  }
  .search input {
    font-size: 1rem;
    text-overflow: ellipsis;
  }
  .search input::placeholder {
    font-size: 0.85rem;
  }
}
/* Na širokim ekranima kolaž ostaje cijeli */
@media (min-width: 1900px) {
  .hero {
    display: flex;
    align-items: center;
    min-height: min(26.2vw, 760px);
  }
}
