/*
 * Archive page ([hakhel_dt_archive]). Tokens, buttons, tags and state panels
 * are in base.css; every rule is scoped under #dt-archive (see there).
 */

/* Hero */
#dt-archive .dt-hero { padding: var(--s7) 0 var(--s5); }
#dt-archive .dt-hero h1 { font-size: 44px; font-weight: 700; }
#dt-archive .dt-lead { font-size: 18px; color: var(--muted); max-width: 820px; margin: var(--s2) 0 0; text-wrap: pretty; } /* pretty: no single word left on the last line. */
#dt-archive .dt-stats { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-top: var(--s4); color: var(--muted); font-size: 15px; }
#dt-archive .dt-stats strong { color: var(--brown); font-family: var(--font-display); font-size: 24px; margin-inline-end: 4px; }

/* Finder */
#dt-archive .dt-finder { position: sticky; top: var(--dt-sticky-top); z-index: 20; background: rgba(254, 252, 247, .94); backdrop-filter: blur(8px); padding: var(--s4); border-radius: var(--r-lg); }
#dt-archive .dt-finder-row { display: flex; gap: var(--s3); align-items: stretch; margin: 0; }
#dt-archive .dt-search { flex: 1; position: relative; }
#dt-archive .dt-search input { display: block; width: 100%; height: 52px; min-height: 0; margin: 0; border: 1.5px solid var(--line); border-radius: 999px; padding: 0 44px 0 52px; padding-inline: 44px 52px; background: var(--white); font-size: 17px; line-height: normal; box-shadow: none; }
#dt-archive .dt-search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(212, 153, 15, .18); }
#dt-archive .dt-search input::-webkit-search-cancel-button { display: none; }
/* Centred with transform, so a theme that changes the input's height doesn't move them. */
#dt-archive .dt-search .dt-icon { position: absolute; inset-inline-start: 18px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
#dt-archive .dt-clear { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 50%; border: 0; background: var(--cream); color: var(--brown); line-height: 1; cursor: pointer; }
#dt-archive .dt-select,
#dt-archive .dt-select-sm,
#dt-archive .dt-input { appearance: none; -webkit-appearance: none; margin: 0; background-color: var(--white); border: 1.5px solid var(--line); box-shadow: none; }
#dt-archive .dt-select,
#dt-archive .dt-select-sm { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235C3A1E' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 16px center; }
#dt-archive .dt-select { height: 52px; border-radius: 999px; padding: 0 18px 0 40px; min-width: 220px; font-size: 16px; }
/* A set width: the live theme makes every select 100% wide, which would take half of the row from the search box. */
#dt-archive .dt-finder-row .dt-select { flex: none; width: 200px; min-width: 0; }
#dt-archive .dt-select-sm { width: 100%; height: 42px; border-radius: var(--r); padding: 0 12px 0 36px; background-position: left 12px center; }
#dt-archive .dt-input { width: 100%; height: 42px; border-radius: var(--r); padding: 0 12px; }
#dt-archive .dt-select:focus,
#dt-archive .dt-select-sm:focus,
#dt-archive .dt-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 153, 15, .18); }
#dt-archive .dt-more-btn { height: 52px; padding: 0 20px; }
#dt-archive .dt-count { background: var(--brown); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; min-width: 20px; text-align: center; }
#dt-archive .dt-more { margin-top: var(--s3); background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--s5); box-shadow: var(--shadow); }
#dt-archive .dt-field { border: 0; padding: 0; margin: 0; min-width: 0; }
#dt-archive .dt-label { display: block; font-size: 13px; font-weight: 600; color: var(--brown); margin-bottom: var(--s2); padding: 0; }
#dt-archive .dt-chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
#dt-archive .dt-chip-toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; color: var(--ink); line-height: 1.4; }
#dt-archive .dt-chip-toggle .dt-n { font-size: 12px; color: var(--muted); }
#dt-archive .dt-chip-toggle[aria-pressed="true"] { background: var(--brown); border-color: var(--brown); color: #fff; }
#dt-archive .dt-chip-toggle[aria-pressed="true"] .dt-n { color: #e6d6c0; }
#dt-archive .dt-segmented { display: flex; border: 1.5px solid var(--line); border-radius: var(--r); overflow: hidden; }
#dt-archive .dt-segmented button { flex: 1; border: 0; border-radius: 0; background: var(--white); color: var(--ink); padding: 8px 6px; cursor: pointer; font-size: 14px; }
#dt-archive .dt-segmented button + button { border-inline-start: 1px solid var(--line); }
#dt-archive .dt-segmented button[aria-pressed="true"] { background: var(--brown); color: #fff; }
#dt-archive .dt-active-row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin-top: var(--s3); }
#dt-archive .dt-active-row:empty { display: none; }
#dt-archive .dt-active-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--cream); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px 3px 6px; padding-inline: 12px 6px; font-size: 14px; }
#dt-archive .dt-active-chip button { border: 0; padding: 0; background: var(--white); width: 22px; height: 22px; border-radius: 50%; cursor: pointer; color: var(--brown); font-size: 11px; line-height: 1; }
#dt-archive .dt-active-chip button:hover { background: var(--brown); color: #fff; }

/* Results */
#dt-archive .dt-results-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; margin: var(--s5) 0 var(--s4); gap: var(--s4); }
#dt-archive .dt-results-count { font-size: 15px; color: var(--muted); }
#dt-archive .dt-results-count strong { color: var(--brown); font-size: 17px; }
#dt-archive .dt-tools { display: flex; gap: var(--s3); align-items: center; }
#dt-archive .dt-sort { height: 38px; width: auto; min-width: auto; padding: 0 14px 0 34px; font-size: 14px; border-width: 1px; background-position: left 12px center; }
#dt-archive .dt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
#dt-archive .dt-more-wrap { text-align: center; margin: var(--s6) 0 0; }

/* Card */
#dt-archive .dt-card { position: relative; background: var(--white); border: 1px solid var(--line); border-inline-start: 4px solid var(--gold); border-radius: var(--r); padding: var(--s5) var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s2); transition: box-shadow .2s, transform .2s; }
#dt-archive .dt-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
#dt-archive .dt-card-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); font-size: 13px; }
#dt-archive .dt-parasha-label { color: var(--gold-ink); font-weight: 500; }
#dt-archive .dt-kind { color: var(--muted); }
#dt-archive .dt-card h3 { font-size: 20px; font-weight: 700; }
#dt-archive .dt-card h3 a { color: inherit; text-decoration: none; }
#dt-archive .dt-card h3 a::after { content: ""; position: absolute; inset: 0; } /* The whole card is one click target and one tab stop. */
#dt-archive .dt-card h3 a:focus-visible { outline: none; }
#dt-archive .dt-card:has(h3 a:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
#dt-archive .dt-by { font-size: 14px; color: var(--muted); }
#dt-archive .dt-by b { color: var(--ink); font-weight: 500; }
#dt-archive .dt-excerpt { font-size: 15px; margin: var(--s1) 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#dt-archive .dt-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: var(--s2); position: relative; z-index: 1; }
#dt-archive mark { background: #FCE9B4; color: inherit; border-radius: 2px; padding: 0 1px; }

/* Skeleton, empty and error states */
#dt-archive .dt-skel { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s5); display: flex; flex-direction: column; gap: 12px; }
#dt-archive .dt-skel i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--cream) 0%, #fbf6ee 50%, var(--cream) 100%); background-size: 200% 100%; animation: dt-shimmer 1.2s infinite; }
@keyframes dt-shimmer { to { background-position: -200% 0; } }

/* No-JavaScript list */
#dt-archive .dt-fallback h2 { font-size: 22px; margin: var(--s5) 0 var(--s2); }
#dt-archive .dt-fallback ul { margin: 0; padding-inline-start: 20px; }

/* Tablet */
@media (max-width: 1023px) {
	#dt-archive .dt-finder-row { flex-wrap: wrap; }
	#dt-archive .dt-search { flex-basis: 100%; }
	#dt-archive .dt-finder-row .dt-select { flex: 1; width: auto; }
	#dt-archive .dt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	#dt-archive .dt-more { grid-template-columns: 1fr 1fr; }
	#dt-archive .dt-topics-field { grid-column: 1 / -1; }
}

/* Phone: sticky search only; the other filters open a bottom sheet (UX spec, Responsive Behavior). */
@media (max-width: 639px) {
	#dt-archive .dt-hero { padding-top: var(--s6); }
	#dt-archive .dt-hero h1 { font-size: 32px; }
	#dt-archive .dt-stats { font-size: 14px; gap: var(--s3); }
	#dt-archive .dt-stats strong { font-size: 20px; }
	/* No backdrop-filter here: it would make the fixed sheet position against the finder. */
	#dt-archive .dt-finder { padding: var(--s3); backdrop-filter: none; background: var(--paper); }
	#dt-archive .dt-finder-row { flex-wrap: nowrap; }
	#dt-archive .dt-search { flex-basis: auto; min-width: 0; }
	#dt-archive .dt-search input { height: 48px; font-size: 16px; }
	#dt-archive .dt-more-btn { height: 48px; padding: 0 14px; }
	#dt-archive .dt-more { position: fixed; inset: auto 0 0 0; z-index: 1000; margin: 0; max-height: 85vh; overflow-y: auto; border-radius: var(--r-lg) var(--r-lg) 0 0; grid-template-columns: 1fr; gap: var(--s4); padding: var(--s4) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 32px rgba(43, 33, 24, .25); }
	#dt-archive .dt-sheet-head { display: flex !important; justify-content: space-between; align-items: center; }
	#dt-archive .dt-sheet-head h3 { font-size: 22px; }
	#dt-archive .dt-sheet-head h3:focus { outline: none; }
	#dt-archive .dt-sheet-close { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--cream); color: var(--brown); cursor: pointer; }
	#dt-archive .dt-sheet-foot { position: sticky; bottom: 0; background: var(--white); padding-top: var(--s2); }
	#dt-archive .dt-sheet-foot .dt-btn { width: 100%; min-height: 48px; }
	#dt-archive .dt-chip-toggle { padding: 10px 16px; }
	#dt-archive .dt-segmented button { min-height: 44px; }
	#dt-archive .dt-active-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
	#dt-archive .dt-active-chip { flex: none; }
	#dt-archive .dt-active-row > .dt-btn { flex: none; }
	#dt-archive .dt-active-chip button { width: 28px; height: 28px; }
	#dt-archive .dt-grid { grid-template-columns: minmax(0, 1fr); }
	#dt-archive .dt-excerpt { -webkit-line-clamp: 2; }
}
html.dt-sheet-open { overflow: hidden; }
html.dt-sheet-open #dt-archive .dt-finder::before { content: ""; position: fixed; inset: 0; background: rgba(43, 33, 24, .4); z-index: 999; }

