:root{
  color-scheme:dark;
  --archive-bg:#ffffff;
  --archive-surface:#f7f7f8;
  --archive-text:#1a1a1a;
  --archive-muted:rgba(26,26,26,.64);
  --archive-faint:rgba(26,26,26,.46);
  --archive-line:rgba(0,0,0,.10);
  --archive-line-strong:rgba(0,0,0,.16);
  --archive-gold:#a02a1e;
  --archive-red:#c0392b;
  --archive-max:1180px;
  --archive-gutter:clamp(18px,4vw,48px);
  --archive-header-offset:78px;
  /* Font stack unified to the charter-approved families (Rule 24: Amiri / Sarabun /
     IBM Plex Sans Thai / Inter). Latin/UI = Inter — the Rule-24 member of the index
     --ui stack; D-DIN is NOT introduced here (it would be a prohibited 5th family). */
  --archive-thai:'Sarabun',system-ui,sans-serif;
  --archive-heading:'IBM Plex Sans Thai',system-ui,sans-serif;
  --archive-ui:'Inter',system-ui,sans-serif
}

*,
*::before,
*::after{box-sizing:border-box}

html{
  background:var(--archive-bg);
  scroll-behavior:smooth;
  scroll-padding-top:calc(var(--archive-header-offset) + 28px)
}

body{
  min-width:320px;
  margin:0;
  overflow-x:hidden;
  background:var(--archive-bg);
  color:var(--archive-text);
  font-family:var(--archive-thai);
  font-weight:400;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility
}

main{display:block}
a{color:inherit;text-decoration:none}
button,input,select{font:inherit}
button,select{color:inherit}
img{display:block;max-width:100%}
[hidden]{display:none!important}

#readingProgress{
  position:fixed;
  top:0;
  left:0;
  z-index:10000;
  width:0;
  height:2px;
  background:var(--archive-red)
}


.archive-masthead{
  border-bottom:1px solid var(--archive-line)
}

.masthead-inner,
.archive-masthead-inner,
.archive-browser-inner{
  width:min(var(--archive-max),calc(100% - (var(--archive-gutter) * 2)));
  margin-inline:auto
}

.masthead-inner,
.archive-masthead-inner{
  padding-block:clamp(72px,8vw,108px) clamp(44px,5vw,62px)
}

.masthead-grid,
.archive-masthead-layout{
  display:grid;
  grid-template-columns:repeat(12,minmax(0,1fr));
  column-gap:clamp(16px,2.4vw,32px);
  row-gap:14px;
  align-items:end
}

.masthead-grid>div:first-child,
.archive-masthead-copy{
  grid-column:1/span 9
}

.archive-eyebrow,
.archive-masthead-eyebrow,
.archive-heading,
.archive-description,
.archive-masthead-description{
  grid-column:1/span 9
}

.archive-eyebrow,
.archive-masthead-eyebrow{
  display:block;
  margin:0 0 11px;
  color:var(--archive-gold);
  font-family:var(--archive-ui);
  font-size:10px;
  font-weight:600;
  line-height:1.4;
  letter-spacing:.14em;
  text-transform:uppercase
}

.archive-heading,
.archive-masthead-copy h1{
  max-width:860px;
  margin:0;
  color:var(--archive-text);
  font-family:var(--archive-heading);
  font-size:clamp(52px,5.2vw,68px);
  font-weight:600;
  line-height:1.08;
  letter-spacing:-.035em;
  text-wrap:balance
}

.archive-description,
.archive-masthead-description{
  max-width:58ch;
  margin:18px 0 0;
  color:var(--archive-muted);
  font-size:16px;
  line-height:1.72
}

.archive-total,
.archive-masthead-total{
  grid-column:11/-1;
  grid-row:1/4;
  align-self:end;
  display:flex;
  align-items:baseline;
  justify-content:flex-end;
  gap:9px;
  margin:0;
  padding-bottom:5px;
  color:var(--archive-muted);
  white-space:nowrap
}

.archive-masthead-total{grid-row:1}

.archive-total strong,
.archive-masthead-total strong{
  color:var(--archive-gold);
  font-family:var(--archive-ui);
  font-size:40px;
  font-weight:500;
  line-height:1;
  letter-spacing:-.035em;
  font-variant-numeric:tabular-nums
}

.archive-total span,
.archive-masthead-total span{
  font-size:13px;
  line-height:1.2
}

.archive-browser{
  width:100%
}

.archive-browser-inner{
  padding-block:0 clamp(88px,10vw,136px)
}

.archive-browser-header{
  padding:46px 0 24px;
  display:grid;
  grid-template-columns:repeat(12,minmax(0,1fr));
  column-gap:clamp(16px,2.4vw,32px)
}

.archive-browser-eyebrow{
  grid-column:1/-1;
  margin:0 0 8px;
  color:var(--archive-gold);
  font-family:var(--archive-ui);
  font-size:10px;
  font-weight:600;
  line-height:1.4;
  letter-spacing:.14em;
  text-transform:uppercase
}

.archive-browser-header h2{
  grid-column:1/span 9;
  margin:0;
  color:var(--archive-text);
  font-family:var(--archive-heading);
  font-size:clamp(30px,3.2vw,42px);
  font-weight:600;
  line-height:1.16;
  letter-spacing:-.025em
}

.archive-toolbar{
  position:sticky;
  top:var(--archive-header-offset);
  z-index:20;
  display:grid;
  grid-template-columns:minmax(280px,1fr) auto 156px;
  grid-template-areas:'search filters sort' 'status status status';
  align-items:stretch;
  gap:0;
  padding:0;
  border:0;
  border:1px solid var(--archive-line);
  border-radius:16px;
  background:rgba(255,255,255,.97)
}
/* glass (index visual language): translucent card + blur + hairline; the
   @supports guard keeps a solid readable fallback when backdrop-filter is
   unavailable. Blur is applied ONLY to the sticky toolbar (real content
   scrolls beneath it) — list cards are translucent-only so 50+ cards never
   stack blur layers on mobile scroll. */
@supports ((backdrop-filter:blur(18px)) or (-webkit-backdrop-filter:blur(18px))){
  .archive-toolbar{
    background:rgba(255,255,255,.78);
    -webkit-backdrop-filter:blur(18px) saturate(1.4);
    backdrop-filter:blur(18px) saturate(1.4)
  }
}

.search-field,
.archive-search-field{
  grid-area:search;
  min-width:0;
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  align-items:center;
  border-right:1px solid var(--archive-line)
}

.search-field label,
.archive-search-field label{
  padding-left:16px;
  color:var(--archive-gold);
  font-size:11px;
  font-weight:500;
  white-space:nowrap
}

.search-field input,
.archive-search-field input{
  width:100%;
  min-width:0;
  min-height:56px;
  padding:0 16px 0 12px;
  border:0;
  border-radius:0;
  outline:0;
  background:transparent;
  color:var(--archive-text);
  font-size:15px
}

.search-field input::placeholder,
.archive-search-field input::placeholder{color:var(--archive-faint)}

.filter-group,
.archive-filter-group{
  grid-area:filters;
  min-width:0;
  display:flex;
  align-items:stretch
}

.filter-button,
.archive-filter-group button{
  min-width:0;
  min-height:56px;
  padding:0 17px;
  border:0;
  border-bottom:2px solid transparent;
  border-radius:0;
  background:transparent;
  color:var(--archive-muted);
  cursor:pointer;
  font-size:13px;
  font-weight:400;
  white-space:nowrap;
  transition:color .16s ease,border-color .16s ease
}

.filter-button:hover,
.archive-filter-group button:hover{color:var(--archive-text)}
.filter-button[aria-pressed='true'],
.archive-filter-group button[aria-pressed='true']{
  border-bottom-color:var(--archive-red);
  color:var(--archive-red)
}

.sort-field,
.archive-sort-field{
  grid-area:sort;
  min-width:0;
  display:grid;
  grid-template-columns:auto minmax(0,1fr);
  align-items:center;
  border-left:1px solid var(--archive-line)
}

.sort-field label,
.archive-sort-field label{
  position:absolute;
  width:1px;
  height:1px;
  margin:-1px;
  overflow:hidden;
  clip:rect(0 0 0 0);
  clip-path:inset(50%);
  white-space:nowrap
}

.sort-field select,
.archive-sort-field select{
  width:100%;
  min-height:56px;
  padding:0 12px;
  border:0;
  border-radius:0;
  outline:0;
  background:var(--archive-bg);
  color:var(--archive-muted);
  cursor:pointer;
  font-size:12px
}

.archive-summary,
.archive-toolbar-status{
  grid-area:status;
  min-height:44px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  margin:0;
  color:var(--archive-muted);
  font-size:13px;
  line-height:1.5
}

.archive-toolbar-status{
  padding-inline:16px;
  border-top:1px solid var(--archive-line)
}

.archive-toolbar-status p{margin:0}

.archive-summary strong,
.archive-toolbar-status strong{
  color:var(--archive-text);
  font-family:var(--archive-ui);
  font-weight:500;
  font-variant-numeric:tabular-nums
}

.clear-button,
#clearFilters,
.archive-toolbar-status button{
  min-height:40px;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  color:var(--archive-gold);
  cursor:pointer;
  font-size:12px;
  text-decoration:underline;
  text-decoration-thickness:1px;
  text-underline-offset:4px
}

.clear-button:hover,
#clearFilters:hover,
.archive-toolbar-status button:hover{color:var(--archive-text)}

.archive-list{
  display:grid;
  border-top:1px solid var(--archive-line)
}

.archive-entry-wrap{
  margin-bottom:14px;
  border:1px solid var(--archive-line);
  border-radius:16px;
  background:rgba(244,236,223,.035);
  overflow:hidden
}
.archive-entry-wrap:hover{border-color:var(--archive-line-strong)}

.archive-entry{
  min-height:0;
  padding:24px clamp(16px,2.4vw,28px);
  display:grid;
  grid-template-columns:minmax(52px,.65fr) minmax(220px,3fr) minmax(0,7.35fr) minmax(52px,1fr);
  grid-template-areas:'index media content action';
  column-gap:clamp(20px,2.7vw,34px);
  align-items:center;
  border-radius:0;
  background:transparent;
  transition:background-color .16s ease
}

.archive-entry:hover{background-color:rgba(244,236,223,.025)}

.entry-index{
  grid-area:index;
  align-self:start;
  padding-top:2px;
  color:var(--archive-muted)
}

.entry-number,
.entry-index-number{
  display:block;
  color:var(--archive-gold);
  font-family:var(--archive-ui);
  font-size:22px;
  font-weight:500;
  line-height:1;
  letter-spacing:.01em;
  font-variant-numeric:tabular-nums
}

.entry-index-label{
  display:block;
  margin-bottom:7px;
  color:var(--archive-faint);
  font-size:10px;
  line-height:1
}

.entry-media{
  grid-area:media;
  position:relative;
  width:100%;
  aspect-ratio:3/2;
  overflow:hidden;
  border:1px solid var(--archive-line);
  border-radius:3px;
  background:var(--archive-surface)
}

.entry-media img{
  width:100%;
  height:100%;
  object-fit:cover
}

.entry-media-fallback{
  position:absolute;
  inset:0;
  display:none;
  place-items:center;
  padding:12px;
  color:var(--archive-faint);
  text-align:center;
  font-size:11px
}

.entry-media.has-image-error .entry-media-fallback{display:grid}

.entry-content{
  grid-area:content;
  min-width:0
}

.entry-category{
  display:block;
  margin:0;
  color:var(--archive-muted);
  font-size:12px;
  font-weight:400;
  line-height:1.4
}

.entry-title{
  max-width:760px;
  margin:7px 0 0;
  color:var(--archive-text);
  font-family:var(--archive-heading);
  font-size:clamp(25px,2.3vw,31px);
  font-weight:600;
  line-height:1.24;
  letter-spacing:-.02em;
  text-wrap:balance
}

.entry-meta,
.entry-place,
.entry-summary,
.entry-alias{
  display:block;
  margin:0
}

.entry-meta{
  margin-top:10px;
  color:var(--archive-muted);
  font-family:var(--archive-ui),var(--archive-thai);
  font-size:11px;
  font-weight:400;
  line-height:1.5;
  letter-spacing:0;
  text-transform:none
}

.entry-place{
  margin-top:5px;
  color:var(--archive-muted);
  font-size:13px;
  line-height:1.5
}

.entry-summary{
  max-width:62ch;
  margin-top:9px;
  color:var(--archive-muted);
  font-size:14px;
  line-height:1.65
}

.entry-alias{
  margin-top:6px;
  color:var(--archive-faint);
  font-family:var(--archive-ui);
  font-size:11px;
  line-height:1.45
}

.entry-action{
  grid-area:action;
  justify-self:end;
  color:var(--archive-muted);
  font-size:13px;
  font-weight:400;
  line-height:1.4;
  text-decoration:underline;
  text-decoration-color:transparent;
  text-decoration-thickness:1px;
  text-underline-offset:4px;
  white-space:nowrap;
  transition:color .16s ease,text-decoration-color .16s ease
}

.archive-entry:hover .entry-action{
  color:var(--archive-gold);
  text-decoration-color:currentColor
}

/* pagination — 6/page. Reuses the shared shadcn windowed pager component
   (window.IFPPager in main.js): the .pg-* markup + look match the article/category
   lists (#pagination in css/index-list.css) exactly, scoped to the archive container
   so คลังอารยธรรม + คลังวิทยาศาสตร์ paginate identically to every other list.
   (science-archive.css @imports this file, so both archives share this one block.) */
.archive-pager{
  display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:4px;
  padding:48px 16px 8px;margin:0 auto
}
.archive-pager .pg-btn{
  box-sizing:border-box;
  min-width:44px;height:44px;padding:0 12px;
  display:inline-flex;align-items:center;justify-content:center;
  font-family:'IBM Plex Sans Thai',system-ui,sans-serif;
  font-size:15px;font-weight:500;line-height:1;
  color:var(--archive-text);background:transparent;
  border:1px solid transparent;border-radius:10px;
  text-decoration:none;cursor:pointer;user-select:none;
  transition:color .18s ease,background-color .18s ease,border-color .18s ease
}
.archive-pager .pg-btn:hover{background:var(--archive-surface);color:var(--archive-text)}
.archive-pager .pg-btn.pg-active{
  background:var(--archive-red);color:#ffffff;font-weight:600;
  border-color:var(--archive-red)
}
.archive-pager .pg-btn.pg-active:hover{background:var(--archive-gold);color:#ffffff}
.archive-pager .pg-btn.pg-disabled{opacity:.38;cursor:default;pointer-events:none}
.archive-pager .pg-btn.pg-prev,.archive-pager .pg-btn.pg-next{padding:0 8px;color:var(--archive-muted)}
.archive-pager .pg-btn:focus-visible{outline:2px solid var(--archive-red);outline-offset:2px}
.archive-pager .pg-ellipsis{
  min-width:28px;height:44px;display:inline-flex;align-items:flex-end;
  justify-content:center;padding-bottom:12px;color:var(--archive-faint);
  font-size:15px;user-select:none
}
@media (max-width:768px){
  .archive-pager{padding:32px 12px 4px;gap:2px}
  .archive-pager .pg-btn{min-width:42px;height:42px;padding:0 8px;font-size:14px}
  .archive-pager .pg-ellipsis{min-width:20px;height:42px;padding-bottom:12px}
}

.archive-error,
.archive-empty{
  margin:0;
  padding:72px 20px;
  border-bottom:1px solid var(--archive-line);
  color:var(--archive-muted);
  text-align:center;
  font-size:14px;
  line-height:1.75
}

.archive-entry:focus-visible,
.filter-button:focus-visible,
.archive-filter-group button:focus-visible,
.search-field input:focus-visible,
.archive-search-field input:focus-visible,
.sort-field select:focus-visible,
.archive-sort-field select:focus-visible,
.clear-button:focus-visible,
#clearFilters:focus-visible,
.archive-toolbar-status button:focus-visible{
  outline:2px solid var(--archive-red);
  outline-offset:3px
}

.search-field input:focus-visible,
.archive-search-field input:focus-visible,
.sort-field select:focus-visible,
.archive-sort-field select:focus-visible{
  outline-offset:-3px
}

@media(max-width:980px){
  .masthead-grid>div:first-child,
  .archive-masthead-copy,
  .archive-eyebrow,
  .archive-masthead-eyebrow,
  .archive-heading,
  .archive-description,
  .archive-masthead-description{grid-column:1/span 8}

  .archive-total,
  .archive-masthead-total{grid-column:10/-1}

  .archive-toolbar{
    grid-template-columns:minmax(0,1fr) 148px;
    grid-template-areas:'search sort' 'filters filters' 'status status'
  }

  .filter-group,
  .archive-filter-group{
    overflow-x:auto;
    border-top:1px solid var(--archive-line);
    scrollbar-width:thin;
    scrollbar-color:var(--archive-line-strong) transparent
  }

  .filter-button,
  .archive-filter-group button{flex:1 0 auto}

  .sort-field,
  .archive-sort-field{border-left:1px solid var(--archive-line)}

  .archive-entry{
    grid-template-columns:48px minmax(180px,2.6fr) minmax(0,6.4fr) 48px;
    column-gap:20px
  }

  .entry-summary{font-size:13px}
}

@media(max-width:700px){
  :root{
    --archive-gutter:16px;
    --archive-header-offset:66px
  }

  .masthead-inner,
  .archive-masthead-inner{padding-block:44px 32px}

  .masthead-grid,
  .archive-masthead-layout{
    grid-template-columns:1fr;
    row-gap:10px
  }

  .masthead-grid>div:first-child,
  .archive-masthead-copy,
  .archive-eyebrow,
  .archive-masthead-eyebrow,
  .archive-heading,
  .archive-masthead-copy h1,
  .archive-description,
  .archive-masthead-description,
  .archive-total,
  .archive-masthead-total{
    grid-column:1;
    grid-row:auto
  }

  .archive-heading,
  .archive-masthead-copy h1{
    max-width:12ch;
    font-size:clamp(38px,10.8vw,44px);
    line-height:1.12;
    letter-spacing:-.03em
  }

  .archive-description,
  .archive-masthead-description{
    margin-top:12px;
    font-size:14px;
    line-height:1.68
  }

  .archive-total,
  .archive-masthead-total{
    justify-content:flex-start;
    gap:7px;
    padding:7px 0 0
  }

  .archive-total strong,
  .archive-masthead-total strong{font-size:28px}
  .archive-total span,
  .archive-masthead-total span{font-size:12px}

  .archive-browser-header{
    padding:34px 0 20px;
    grid-template-columns:1fr
  }

  .archive-browser-eyebrow,
  .archive-browser-header h2{grid-column:1}

  .archive-browser-header h2{font-size:30px}

  .archive-toolbar{
    position:relative;
    top:auto;
    z-index:1;
    grid-template-columns:minmax(0,1fr) 116px;
    grid-template-areas:'search sort' 'filters filters' 'status status';
    -webkit-backdrop-filter:none;
    backdrop-filter:none
  }

  .search-field label,
  .archive-search-field label{
    position:absolute;
    width:1px;
    height:1px;
    margin:-1px;
    overflow:hidden;
    clip:rect(0 0 0 0);
    clip-path:inset(50%);
    white-space:nowrap
  }

  .search-field input,
  .archive-search-field input{
    min-height:48px;
    padding-inline:12px;
    font-size:14px
  }

  .sort-field select,
  .archive-sort-field select{
    min-height:48px;
    padding-inline:9px;
    font-size:11px
  }

  .filter-button,
  .archive-filter-group button{
    min-height:48px;
    padding-inline:15px;
    font-size:12px
  }

  .archive-summary,
  .archive-toolbar-status{
    min-height:42px;
    gap:12px;
    font-size:12px
  }

  .clear-button,
  #clearFilters,
  .archive-toolbar-status button{
    min-height:38px;
    font-size:11px;
    text-align:right
  }

  .archive-entry{
    padding:18px 0;
    grid-template-columns:88px minmax(0,1fr);
    grid-template-rows:auto 1fr;
    grid-template-areas:'media index' 'media content';
    column-gap:14px;
    row-gap:5px;
    align-items:start
  }

  .entry-index{
    display:flex;
    align-items:baseline;
    gap:6px;
    padding:0
  }

  .entry-index-label{margin-bottom:0}

  .entry-number,
  .entry-index-number{font-size:16px}

  .entry-media{
    width:88px;
    height:88px;
    aspect-ratio:auto;
    border-radius:2px
  }

  .entry-content{align-self:start}

  .entry-category{
    font-size:11px;
    line-height:1.3
  }

  .entry-title{
    margin-top:4px;
    font-size:clamp(19px,5.5vw,22px);
    line-height:1.3;
    letter-spacing:-.015em
  }

  .entry-meta{
    margin-top:7px;
    font-size:9px;
    line-height:1.45
  }

  .entry-place{
    margin-top:4px;
    overflow:hidden;
    color:var(--archive-faint);
    font-size:11px;
    line-height:1.4;
    text-overflow:ellipsis;
    white-space:nowrap
  }

  .entry-summary,
  .entry-alias,
  .entry-action{display:none}

}

@media(max-width:420px){
  .archive-heading,
  .archive-masthead-copy h1{font-size:38px}
  .archive-description,
  .archive-masthead-description{max-width:34ch}
  .archive-toolbar{grid-template-columns:minmax(0,1fr) 108px}
  .filter-button,
  .archive-filter-group button{padding-inline:13px}
  .entry-meta{display:none}
}

@media(prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  .filter-button,
  .archive-filter-group button,
  .archive-entry,
  .entry-action{transition:none}
}
