/* ============================================================
   Archivio Cirese — Custom CSS for Omeka S Foundation theme
   Style: clean, minimal, scholarly
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Inter:wght@300;400;500;600&display=swap');

/* --- CSS Variables --- */
:root {
  --ac-bg:         #faf9f7;
  --ac-surface:    #f3f1ed;
  --ac-border:     #e2ddd6;
  --ac-text:       #1a1814;
  --ac-text-muted: #6b6560;
  --ac-accent:     #8b3a2a;
  --ac-accent-lt:  #c0614e;
  --ac-accent-bg:  #f7ece9;
  --ac-link:       #8b3a2a;
  --ac-nav-bg:     #1a1814;
  --ac-nav-text:   #f3f1ed;
  --ff-serif:      'EB Garamond', Georgia, serif;
  --ff-sans:       'Inter', system-ui, sans-serif;
  --max-w:         1080px;
}

/* --- Base --- */
body {
  background: var(--ac-bg);
  color: var(--ac-text);
  font-family: var(--ff-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--ff-serif);
  font-weight: 500;
  line-height: 1.25;
  color: var(--ac-text);
  letter-spacing: -0.01em;
}

h1 { font-size: 2.8rem; margin-bottom: 1rem; }
h2 { font-size: 2rem;   margin-bottom: 0.875rem; }
h3 { font-size: 1.4rem; margin-bottom: 0.75rem; }

p { margin-bottom: 1.25rem; color: var(--ac-text); }

a {
  color: var(--ac-link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}
a:hover {
  color: var(--ac-accent-lt);
  border-bottom-color: var(--ac-accent-lt);
}

/* --- Layout --- */
.container, #content .container {
  max-width: var(--max-w);
  padding: 0 2rem;
}

#content {
  padding: 3rem 0 4rem;
}

/* --- Navigation --- */
nav#site-nav, .top-bar, header nav {
  background: var(--ac-nav-bg) !important;
  border-bottom: none;
  padding: 0 2rem;
}

.top-bar ul, nav#site-nav ul {
  background: var(--ac-nav-bg) !important;
}

.top-bar ul li a,
nav#site-nav ul li a {
  color: var(--ac-nav-text) !important;
  font-family: var(--ff-sans);
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1.1rem 1.25rem;
  border-bottom: none !important;
  transition: color 0.2s;
}

.top-bar ul li a:hover,
nav#site-nav ul li a:hover,
.top-bar ul li.active a,
nav#site-nav ul li.active a {
  color: #d4957f !important;
  background: transparent !important;
}

/* Site title in nav */
.top-bar .site-title a,
header .site-title a {
  font-family: var(--ff-serif);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ac-nav-text) !important;
  letter-spacing: 0.02em;
  border-bottom: none !important;
}

/* Search in nav */
.top-bar input[type="search"],
.top-bar input[type="text"] {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--ac-nav-text);
  border-radius: 3px;
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
}

.top-bar input[type="submit"],
.top-bar button[type="submit"] {
  background: var(--ac-accent);
  border: none;
  color: white;
  font-size: 0.875rem;
  padding: 0.4rem 0.875rem;
  border-radius: 3px;
  cursor: pointer;
}

/* --- Buttons --- */
.button, button, input[type="submit"] {
  background: var(--ac-accent) !important;
  border: none !important;
  border-radius: 3px !important;
  font-family: var(--ff-sans) !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  letter-spacing: 0.03em !important;
  padding: 0.6rem 1.25rem !important;
  color: white !important;
  transition: background 0.2s !important;
  cursor: pointer;
}

.button:hover, button:hover, input[type="submit"]:hover {
  background: var(--ac-accent-lt) !important;
  color: white !important;
}

.button.secondary {
  background: transparent !important;
  border: 1px solid var(--ac-accent) !important;
  color: var(--ac-accent) !important;
}

/* --- Item set cards (fonds on home page) --- */
.resource-list .resource,
.item-set-list .item-set,
ul.item-sets li {
  border: 0.5px solid var(--ac-border) !important;
  border-radius: 6px !important;
  padding: 1.5rem !important;
  margin-bottom: 1rem !important;
  background: white !important;
  transition: box-shadow 0.2s, border-color 0.2s !important;
  box-shadow: none !important;
}

.resource-list .resource:hover,
.item-set-list .item-set:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.08) !important;
  border-color: var(--ac-accent) !important;
}

.resource-list .resource h4 a,
.resource-list .resource h3 a,
ul.item-sets li a {
  font-family: var(--ff-serif);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ac-accent) !important;
  border-bottom: none !important;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

table th {
  background: var(--ac-surface);
  color: var(--ac-text-muted);
  font-family: var(--ff-sans);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ac-border);
  text-align: left;
}

table td {
  padding: 0.75rem 1rem;
  border-bottom: 0.5px solid var(--ac-border);
  color: var(--ac-text);
  font-family: var(--ff-sans);
}

table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--ac-surface); }

/* --- Page content --- */
.page-content, #content .page-content {
  max-width: 720px;
}

/* --- Metadata / item view --- */
.property {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.5rem 1.5rem;
  padding: 0.75rem 0;
  border-bottom: 0.5px solid var(--ac-border);
  font-size: 0.9rem;
}

.property h4 {
  font-family: var(--ff-sans);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ac-text-muted);
  margin: 0;
}

.property .value {
  font-family: var(--ff-sans);
  color: var(--ac-text);
  margin: 0;
}

/* --- Breadcrumbs --- */
nav.breadcrumbs, ul.breadcrumbs {
  font-size: 0.8rem;
  color: var(--ac-text-muted);
  margin-bottom: 2rem;
  padding: 0;
  list-style: none;
}

ul.breadcrumbs li { display: inline; }
ul.breadcrumbs li::after { content: " › "; color: var(--ac-border); }
ul.breadcrumbs li:last-child::after { content: ""; }

/* --- Pagination --- */
ul.pagination li a {
  color: var(--ac-accent);
  border: 0.5px solid var(--ac-border);
  border-radius: 3px;
  padding: 0.3rem 0.6rem;
  font-size: 0.875rem;
}

ul.pagination li.current a {
  background: var(--ac-accent);
  color: white;
  border-color: var(--ac-accent);
}

/* --- Footer --- */
footer {
  border-top: 0.5px solid var(--ac-border);
  padding: 2rem 0;
  font-size: 0.8rem;
  color: var(--ac-text-muted);
  font-family: var(--ff-sans);
}

/* --- Utility --- */
.text-muted { color: var(--ac-text-muted); }
.font-serif { font-family: var(--ff-serif); }

/* --- Responsive --- */
@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  .container { padding: 0 1rem; }
  #content { padding: 2rem 0; }
  .property { grid-template-columns: 1fr; }
}

/* ============================================================
   Patch 1 — Fix remaining blue elements
   ============================================================ */

/* Foundation specific button overrides */
.button,
.button.primary,
a.button,
a.button.primary,
input[type="submit"],
button[type="submit"] {
  background-color: var(--ac-accent) !important;
  border-color: var(--ac-accent) !important;
  color: #fff !important;
}

.button:hover,
.button.primary:hover,
a.button:hover {
  background-color: var(--ac-accent-lt) !important;
  border-color: var(--ac-accent-lt) !important;
}

/* Search button in nav */
.top-bar .button,
.top-bar input[type="submit"],
.top-bar button {
  background-color: var(--ac-accent) !important;
  border-color: var(--ac-accent) !important;
  color: #fff !important;
  border-radius: 3px !important;
}

/* More top padding on main content */
#content {
  padding-top: 4rem !important;
}

/* Hide "Browse all" text link from anteprima block */
.resource-list + p a[href*="browse"],
.resource-list ~ p a {
  font-size: 0.85rem;
  color: var(--ac-text-muted);
  border-bottom: 1px solid var(--ac-border);
  font-family: var(--ff-sans);
}

/* Seguente / pagination buttons */
.button.hollow,
a.button.hollow {
  background: transparent !important;
  border: 1px solid var(--ac-accent) !important;
  color: var(--ac-accent) !important;
}

/* Resource list — remove bottom margin on last item */
.resource-list .resource:last-child {
  margin-bottom: 0 !important;
}

/* Site title styling */
header .site-title,
.top-bar .title-bar-title {
  font-family: var(--ff-serif) !important;
  font-size: 1.1rem !important;
  letter-spacing: 0.05em !important;
}

/* ============================================================
   Patch 2 — High specificity Foundation button override
   ============================================================ */

body .button,
body a.button,
body button.button,
html body .button,
.orbit-container .button,
#content .button,
#content a.button {
  background-color: #8b3a2a !important;
  border-color: #8b3a2a !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

body .button:hover,
body a.button:hover,
#content .button:hover {
  background-color: #c0614e !important;
  border-color: #c0614e !important;
  color: #ffffff !important;
}

/* Hide Browse all link from anteprima preview block */
.preview-block a.button[href*="browse"],
section.preview a.button,
.preview a.button {
  background: transparent !important;
  color: #8b3a2a !important;
  border: 1px solid #8b3a2a !important;
  font-size: 0.8rem !important;
}

/* ============================================================
   Patch 3 — Nuclear button override + sort UI fixes
   ============================================================ */

/* Override Foundation's inline button styles */
[class*="button"]:not([class*="close"]),
a[class*="button"]:not([class*="close"]) {
  background-color: #8b3a2a !important;
  border-color: #8b3a2a !important;
  color: #ffffff !important;
}

[class*="button"]:not([class*="close"]):hover,
a[class*="button"]:not([class*="close"]):hover {
  background-color: #c0614e !important;
  border-color: #c0614e !important;
}

/* Specifically target Foundation's .button class */
.button:not(.close-button):not(.menu-icon) {
  background-color: #8b3a2a !important;
  color: #fff !important;
  border: none !important;
}

/* Item browse page — sort/pagination controls */
.browse .sort-options select,
.item-browse select {
  border: 0.5px solid var(--ac-border);
  border-radius: 3px;
  font-family: var(--ff-sans);
  font-size: 0.875rem;
  color: var(--ac-text);
  background: white;
  padding: 0.4rem 0.75rem;
}

/* Browse page item titles */
.browse article h4 a,
.browse article h3 a,
.item-list h4 a,
.item-list h3 a {
  font-family: var(--ff-serif);
  font-size: 1.1rem;
  color: var(--ac-accent) !important;
  border-bottom: none !important;
}

.browse article h4 a:hover,
.browse article h3 a:hover {
  color: var(--ac-accent-lt) !important;
}

/* Browse page descriptions */
.browse article p,
.item-list p {
  font-size: 0.875rem;
  color: var(--ac-text-muted);
  line-height: 1.5;
  margin-bottom: 0;
}

/* Ricerca avanzata link */
a[href*="advanced"] {
  font-size: 0.8rem;
  color: var(--ac-text-muted);
  border-bottom: 1px solid var(--ac-border);
}

/* ============================================================
   Patch 4 — Truncate descriptions on browse/list pages
   ============================================================ */

/* Truncate description on item browse/list pages */
.browse .resource .description,
.item-list .resource .description,
.resource-list .resource .description,
.browse article .description,
.item-list article .description {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 4.8em;
  font-size: 0.875rem;
  color: var(--ac-text-muted);
  line-height: 1.6;
}

/* Truncate on item set (fondo) browse pages */
.item-set-list .description,
.item-sets .description {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Full description visible on single item page */
#content .show .description,
#content .resource.show .description,
.item.show .description {
  display: block;
  max-height: none;
  overflow: visible;
  -webkit-line-clamp: unset;
}

/* Also truncate the dcterms:description property on list views */
.resource-list .property.dcterms-description .value,
.item-list .property.dcterms-description .value {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
   Patch 5 — Even grid cards on browse pages
   ============================================================ */

/* Make browse grid use CSS grid for even card heights */
.browse .resource-list,
.item-list,
ul.resource-list {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
  gap: 1.25rem !important;
}

.browse .resource-list .resource,
.item-list .resource,
ul.resource-list li {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  margin-bottom: 0 !important;
  padding: 1.25rem !important;
}

.browse .resource-list .resource h4,
.browse .resource-list .resource h3 {
  margin-bottom: 0.5rem;
}

.browse .resource-list .resource .description {
  flex: 1;
  margin-bottom: 0;
}

/* ============================================================
   Patch 6 — Hide duplicate Segnatura + breadcrumb styling
   ============================================================ */

/* Hide Segnatura field (duplicates Identificativo) */
.property.arch-segnatura,
.property[class*="segnatura"] {
  display: none !important;
}

/* Breadcrumb styling */
ul.breadcrumbs,
nav.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0 0 2rem 0;
  font-size: 0.8rem;
  font-family: var(--ff-sans);
  color: var(--ac-text-muted);
}

ul.breadcrumbs li::after {
  content: "›";
  margin-left: 0.25rem;
  color: var(--ac-border);
}

ul.breadcrumbs li:last-child::after {
  content: "";
}

ul.breadcrumbs li a {
  color: var(--ac-text-muted);
  border-bottom: 1px solid var(--ac-border);
}

ul.breadcrumbs li a:hover {
  color: var(--ac-accent);
  border-bottom-color: var(--ac-accent);
}

ul.breadcrumbs li:last-child {
  color: var(--ac-text);
  font-weight: 500;
}

/* ============================================================
   Patch 7 — Fix Segnatura hide (broader selectors)
   ============================================================ */

/* Try all possible class combinations Omeka S might generate */
.property.arch-segnatura,
.property.archivio-cirese-ontology-segnatura,
.property[class*="segnatura"],
.values[data-property-term="arch:segnatura"],
div.property:has(h4 span[lang]:empty + *) {
  display: none !important;
}

/* Target by the label text content as fallback */
.property h4 abbr[title="https://archivio-cirese.it/ontology#segnatura"] ~ .values,
.property:has(h4 abbr[title*="segnatura"]) {
  display: none !important;
}

/* ============================================================
   Image grid — two columns side by side
   ============================================================ */

.image-grid {
  display: -webkit-box !important;
  display: -ms-flexbox !important;
  display: flex !important;
  -ms-flex-wrap: nowrap !important;
  flex-wrap: nowrap !important;
  gap: 1.5rem !important;
  margin: 2rem 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.image-grid figure {
  margin: 0 !important;
  -webkit-box-flex: 1 !important;
  -ms-flex: 1 1 0% !important;
  flex: 1 1 0% !important;
  min-width: 0 !important;
  overflow: hidden !important;
}

.image-grid figure img {
  width: 100% !important;
  height: 260px !important;
  -o-object-fit: cover !important;
  object-fit: cover !important;
  -o-object-position: center top !important;
  object-position: center top !important;
  display: block !important;
  max-width: none !important;
}

.image-grid figcaption {
  font-size: 0.8rem !important;
  color: var(--ac-text-muted) !important;
  margin-top: 0.5rem !important;
  font-style: italic !important;
}

@media (max-width: 640px) {
  .image-grid {
    -ms-flex-wrap: wrap !important;
    flex-wrap: wrap !important;
  }
  .image-grid figure {
    -ms-flex: 1 1 100% !important;
    flex: 1 1 100% !important;
  }
}

/* ============================================================
   Patch 9 — CSS-only carousel for AMC page
   ============================================================ */

.css-carousel {
  width: 100%;
  margin: 2rem 0;
}

.css-carousel input[type="radio"] {
  display: none;
}

.css-carousel .slides {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.css-carousel .slide {
  display: none;
  width: 100%;
}

.css-carousel #s1:checked ~ .slides .slide:nth-child(1),
.css-carousel #s2:checked ~ .slides .slide:nth-child(2),
.css-carousel #s3:checked ~ .slides .slide:nth-child(3),
.css-carousel #s4:checked ~ .slides .slide:nth-child(4),
.css-carousel #s5:checked ~ .slides .slide:nth-child(5) {
  display: block;
}

.css-carousel .slide img {
  width: 100%;
  height: auto;
  display: block;
}

.css-carousel .slide figcaption {
  font-size: 0.8rem;
  color: #6b6560;
  margin-top: 0.4rem;
  font-style: italic;
}

.css-carousel .dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.css-carousel .dots label {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e2ddd6;
  cursor: pointer;
  transition: background 0.2s;
}

.css-carousel #s1:checked ~ .dots label[for="s1"],
.css-carousel #s2:checked ~ .dots label[for="s2"],
.css-carousel #s3:checked ~ .dots label[for="s3"],
.css-carousel #s4:checked ~ .dots label[for="s4"],
.css-carousel #s5:checked ~ .dots label[for="s5"] {
  background: #8b3a2a;
}

/* ============================================================
   Patch 10 — Force full width content on site pages
   ============================================================ */

/* Remove sidebar on site pages */
.site-page #content .resource,
.site-page #content article,
body.site #content .property,
body.site .resource-meta {
  float: none !important;
  width: 100% !important;
}

/* Force page content to use full container width */
body.site #content .page,
body.site #content section.content,
.page-content {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
  margin-right: 0 !important;
  padding-right: 0 !important;
}

/* Hide right sidebar on pages */
body.site #content aside,
body.site #content .secondary-nav,
body.site .page aside {
  display: none !important;
}

/* Make main content fill full width */
body.site #content .medium-8,
body.site #content .medium-9,
body.site #content .large-8,
body.site #content .large-9 {
  width: 100% !important;
  float: none !important;
}

/* ============================================================
   Patch 11 — Fix Foundation float on images in page content
   ============================================================ */

/* Stop Foundation floating images next to captions */
body.site .page-content figure,
body.site .page figure,
#content figure {
  float: none !important;
  clear: both !important;
  margin: 0 !important;
  display: block !important;
}

body.site .page-content figure img,
body.site .page figure img,
#content figure img {
  float: none !important;
  margin: 0 !important;
  display: block !important;
  max-width: 100% !important;
}

body.site .page-content figcaption,
body.site .page figcaption,
#content figcaption {
  float: none !important;
  width: 100% !important;
  display: block !important;
  clear: both !important;
}

/* Gallery table — force cells to display correctly */
#content table td figure {
  display: block !important;
  float: none !important;
}
