/* Portugal Through Time — scoped, responsive visual system */
:root {
  --wine: #641f32;
  --wine-deep: #421522;
  --wine-soft: #8e4754;
  --green: #1f5a43;
  --green-dark: #153f30;
  --gold: #bd9655;
  --gold-light: #ddc89f;
  --paper: #f7f1e7;
  --paper-bright: #fffaf2;
  --sand: #e9decc;
  --ink: #29231e;
  --muted: #766c62;
  --line: #ded0bc;
  --white: #fffdf8;
  --shadow: 0 18px 45px rgba(56, 31, 22, .12);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", Arial, sans-serif;
  --content: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
html {
    scroll-behavior: smooth;
    scroll-padding-top: 90px;
}

body { margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    line-height: 1.65;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
}

button, input, select {
    font: inherit;
}

button, a, input, select {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
}

::selection {
    background: var(--gold-light);
    color: var(--wine-deep);
}

.skip-link {
    position: fixed;
    z-index: 999;
    top: 8px;
    left: 8px;
    padding: 10px 14px;
    transform: translateY(-150%);
    background: var(--wine-deep);
    color: white;
}

.skip-link:focus {
    transform: translateY(0);
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.site-shell {
    overflow: clip;
}

.section-wrap {
    width: min(var(--content), calc(100% - 56px));
    margin-inline: auto;
}

.top-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 7px 16px;
    background: var(--wine-deep);
    color: #f7ead9;
    text-align: center;
    font-size: .69rem;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.top-note__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold-light);
}

.site-header {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 91px;
    padding: 15px max(28px, calc((100vw - var(--content)) / 2));
    border-bottom: 1px solid rgba(100,31,50,.1);
    background: rgba(247,241,231,.96);
    backdrop-filter: blur(16px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--wine);
    text-decoration: none;
    flex: 0 0 auto;
}

.brand__crest {
    position: relative;
    display: grid;
    width: 43px;
    height: 49px;
    place-items: center;
    border: 2px solid var(--gold);
    border-radius: 45% 45% 48% 48% / 22% 22% 62% 62%;
    background: var(--wine);
    box-shadow: inset 0 0 0 3px rgba(255,255,255,.1);
    clip-path: polygon(0 0,100% 0,100% 72%,50% 100%,0 72%);
}

.brand__shield {
    display: grid;
    place-items: center;
    width: 25px;
    height: 29px;
    border: 1px solid var(--gold-light);
    color: var(--gold-light);
    font-size: 15px;
}

.brand__words {
    display: grid;
    line-height: 1.16;
}

.brand__name {
    font-family: var(--serif);
    font-size: 1.17rem;
    font-weight: 800;
    letter-spacing: .1em;
}

.brand__tagline {
    margin-top: 5px;
    color: var(--muted);
    font-size: .56rem;
    font-weight: 700;
    letter-spacing: .19em;
}

.main-navigation {
    display: flex;
    align-items: center;
    gap: clamp(16px, 3vw, 38px);
}

.nav-link {
    position: relative;
    padding: 12px 0;
    color: #665a52;
    text-decoration: none;
    font-size: .83rem;
    font-weight: 600;
    transition: color .2s ease;
}

.nav-link::after {
    position: absolute;
    right: 0;
    bottom: 5px;
    left: 0;
    height: 2px;
    transform: scaleX(0);
    transform-origin: left;
    background: var(--gold);
    content: "";
    transition: transform .2s ease;
}

.nav-link:hover,
.nav-link.is-active {
    color: var(--wine);
}

.nav-link.is-active::after,
.nav-link:hover::after {
    transform: scaleX(1);
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 19px;
    height: 2px;
    margin: 4px auto;
    background: var(--wine);
    transition: transform .2s;
}


/* Hero */
.hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
    align-items: center;
    gap: clamp(36px, 6vw, 82px);
    min-height: 610px;
    padding-top: 69px;
    padding-bottom: 82px;
}

.hero__copy {
    position: relative;
    z-index: 2;
    padding-bottom: 8px;
}

.eyebrow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 17px;
    color: var(--wine);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .17em;
    line-height: 1.4;
    text-transform: uppercase;
}

.eyebrow__line {
    display: inline-block;
    width: 27px;
    height: 1px;
    background: var(--gold);
}

h1, h2, h3, p, figure {
    margin-top: 0;
}

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 600;
    line-height: 1.15;
}

.hero h1 {
    margin-bottom: 22px;
    color: var(--wine-deep);
    font-size: clamp(3.4rem, 6.4vw, 5.75rem);
    letter-spacing: -.055em;
}

.hero h1 em, h2 em {
    color: var(--wine-soft);
    font-weight: 500;
}

.hero__lead {
    max-width: 505px;
    margin-bottom: 30px;
    color: #665a50;
    font-size: 1.02rem;
    line-height: 1.9;
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 23px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 49px;
    padding: 12px 20px;
    border: 1px solid transparent;
    text-decoration: none;
    font-size: .79rem;
    font-weight: 700;
    letter-spacing: .01em;
    transition: transform .2s ease, background .2s ease, color .2s ease;
}

.button:hover {
    transform: translateY(-2px);
}

.button--primary {
    background: var(--wine);
    color: var(--white);
    box-shadow: 0 8px 22px rgba(100,31,50,.16);
}

.button--primary:hover {
    background: var(--wine-deep);
}

.button--light {
    border-color: rgba(255,250,242,.6);
    background: transparent;
    color: var(--white);
}

.button--light:hover {
    background: var(--white);
    color: var(--wine);
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--wine);
    text-decoration: none;
    font-size: .81rem;
    font-weight: 700;
}

.text-link span {
    transition: transform .2s ease;
}

.text-link:hover span {
    transform: translateX(4px);
}

.hero__footnote {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 53px;
    color: var(--muted);
    font-size: .77rem;
    line-height: 1.5;
}

.hero__footnote strong {
    color: var(--wine);
    font-weight: 700;
}

.hero__seal { display: grid;
    width: 37px;
    height: 37px;
    place-items: center;
    border: 1px solid var(--gold);
    border-radius: 50%;
    color: var(--gold);
    font-size: 1.1rem;
}

.hero__visual {
    position: relative;
    min-width: 0;
    padding: 0 12px 17px 0;
}

.hero__image-frame {
    position: relative;
    z-index: 1;
    padding: 11px;
    border: 1px solid var(--gold);
    background: var(--paper-bright);
    box-shadow: var(--shadow);
    transform: rotate(1.4deg);
}

.hero__image-frame::before {
    position: absolute;
    z-index: -1;
    top: 12px;
    right: 12px;
    bottom: -12px;
    left: -12px;
    border: 1px solid var(--gold-light);
    content: "";
}

.hero__image {
    width: 100%;
    height: clamp(350px, 42vw, 490px);
    object-fit: cover;
    filter: saturate(.82) sepia(.1);
}

.hero__image-caption {
    position: absolute;
    right: 11px;
    bottom: 11px;
    left: 11px;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 17px 19px;
    background: rgba(42,25,20,.8);
    color: var(--white);
    backdrop-filter: blur(8px);
}

.caption-mark {
    color: var(--gold-light);
    font-size: 1.45rem;
}

.hero__image-caption strong,
.hero__image-caption small {
    display: block;
}

.hero__image-caption strong {
    font-family: var(--serif);
    font-size: 1rem;
}

.hero__image-caption small {
    color: #e9d9c8;
    font-size: .68rem;
}

.hero__stamp {
    position: absolute;
    z-index: 2;
    top: -26px;
    right: -14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 91px;
    height: 91px;
    border: 1px solid var(--gold);
    border-radius: 50%;
    background: var(--paper);
    color: var(--wine);
    box-shadow: 0 0 0 5px var(--paper);
    transform: rotate(11deg);
}

.hero__stamp span {
    font-size: .45rem;
    font-weight: 700;
    letter-spacing: .13em;
}

.hero__stamp strong {
    font-family: var(--serif);
    font-size: 1.65rem;
    line-height: 1;
}

.hero__side-label {
    position: absolute;
    right: -28px;
    bottom: 45px;
    color: var(--wine);
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: .18em;
    writing-mode: vertical-rl;
}

.hero__bottom-rule {
    position: absolute;
    right: 0;
    bottom: 32px;
    left: 0;
    display: grid;
    grid-template-columns: 1fr 7px 1fr;
    align-items: center;
    gap: 9px;
    opacity: .8;
}

.hero__bottom-rule span {
    height: 1px;
    background: var(--line);
}

.hero__bottom-rule span:nth-child(2) {
    width: 7px;
    height: 7px;
    background: var(--gold);
    transform: rotate(45deg);
}

/* Introduction */
.intro {
    padding-top: 53px;
    padding-bottom: 92px;
    border-top: 1px solid var(--line);
}

.intro__kicker {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 27px;
    color: var(--wine);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .15em;
}

.intro__kicker > span:first-child {
    color: var(--gold);
    font-family: var(--serif);
    font-size: 1.1rem;
}

.mini-rule {
    width: 31px;
    height: 1px;
    background: var(--gold);
}

.intro__body {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: clamp(32px, 7vw, 115px);
    align-items: start;
}

.intro h2,
.section-heading h2,
.page-intro h2,
.feature-layout h2 {
    margin-bottom: 0;
    color: var(--wine-deep);
    font-size: clamp(2.2rem, 4vw, 3.45rem);
    letter-spacing: -.035em;
}

.intro__text {
    max-width: 520px;
    color: #685d52;
    font-size: .91rem;
}

.intro__text p {
    margin-bottom: 16px;
}

.intro__text .text-link {
    margin-top: 8px;
}

/* Timeline preview */
.timeline-preview {
    padding-top: 2px;
    padding-bottom: 102px;
}

.section-heading {
    margin-bottom: 32px;
}

.section-heading--row {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
}

.section-heading .eyebrow {
    margin-bottom: 12px;
}

.section-heading h2 {
    font-size: clamp(2rem, 3.3vw, 3rem);
}

.section-heading--row >
.text-link {
    margin-bottom: 9px;
    white-space: nowrap;
}

.milestone-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.milestone {
    position: relative;
    min-height: 176px;
    padding: 27px 23px 26px 0;
    text-align: left;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.milestone:not(:first-child) {
    padding-left: 22px;
    border-left: 1px solid var(--line);
}

.milestone__date {
    display: block;
    margin-bottom: 13px;
    color: var(--wine);
    font-family: var(--serif);
    font-size: 1.22rem;
}

.milestone__title {
    display: block;
    max-width: 210px;
    margin-bottom: 10px;
    font-size: .85rem;
    font-weight: 700;
    line-height: 1.35;
}

.milestone__text {
    display: block;
    color: var(--muted);
    font-size: .73rem;
    line-height: 1.6;
}

.milestone::after {
    position: absolute;
    right: 0;
    bottom: -4px;
    left: 0;
    height: 3px;
    transform: scaleX(0);
    transform-origin: left;
    background: var(--gold);
    content: "";
    transition: transform .2s ease;
}

.milestone:hover::after,
.milestone:focus-visible::after {
    transform: scaleX(1);
}

/* Feature band */
.feature-band {
    background: var(--wine);
    color: var(--white);
}

.feature-band__inner {
    padding-top: 86px;
    padding-bottom: 86px;
}

.feature-layout {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    align-items: center;
    gap: clamp(36px, 7vw, 95px);
}

.eyebrow--light {
    color: var(--gold-light);
}

.feature-layout h2 {
    margin-bottom: 21px;
    color: var(--white);
    font-size: clamp(2.35rem, 4.1vw, 3.6rem);
}

.feature-layout h2 em {
    color: var(--gold-light);
}

.feature-layout__copy >
p:not(.eyebrow) {
    max-width: 465px;
    margin-bottom: 26px;
    color: #f0e2d9;
    font-size: .9rem;
    line-height: 1.9;
}

.feature-layout__image-wrap {
    position: relative;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--gold);
    background: rgba(255,255,255,.05);
}

.feature-layout__image-wrap img {
    width: 100%;
    height: 370px;
    object-fit: cover;
    filter: sepia(.15) saturate(.8);
}

.feature-layout__image-wrap figcaption {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 3px 1px;
    color: var(--gold-light);
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .16em;
}

/* People */
.people-preview {
    padding-top: 97px;
    padding-bottom: 94px;
}

.people-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 19px;
}

.people-grid--preview {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.person-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--line);
    background: var(--paper-bright);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.person-card:hover {
    transform: translateY(-4px);
    border-color: var(--gold);
    box-shadow: 0 13px 28px rgba(56,31,22,.09);
}

.person-card__button {
    display: flex;
    flex: 1;
    flex-direction: column;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.person-card__portrait {
    position: relative;
    display: grid;
    min-height: 140px;
    place-items: center;
    overflow: hidden;
    background: var(--sand);
    color: var(--wine);
}

.person-card__portrait::after {
    position: absolute;
    inset: 0;
    border: 8px solid rgba(255,250,242,.24);
    content: "";
    pointer-events: none;
}

.person-card__initials {
    display: grid;
    width: 73px;
    height: 73px;
    place-items: center;
    border: 1px solid rgba(100,31,50,.45);
    border-radius: 50%;
    color: var(--wine);
    font-family: var(--serif);
    font-size: 1.8rem;
}

.person-card__portrait img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: sepia(.17) saturate(.75);
}
.person-card__portrait--green {
    background: #d9e0d4;
    color: var(--green);
}

.person-card__portrait--blue {
    background: #d7e1e3;
}

.person-card__portrait--rose {
    background: #ead8d2;
}

.person-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 17px 17px 18px;
}

.person-card__years {
    margin-bottom: 5px;
    color: var(--wine-soft);
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .06em;
}

.person-card__name {
    margin-bottom: 8px;
    color: var(--wine-deep);
    font-family: var(--serif);
    font-size: 1.14rem;
    line-height: 1.3;
}

.person-card__role {
    margin-bottom: 0;
    color: var(--muted);
    font-size: .74rem;
    line-height: 1.6;
}

.person-card__more {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 16px;
    color: var(--wine);
    font-size: .7rem;
    font-weight: 700;
}

/* Quote */
.quote-band {
    position: relative;
    padding: 69px 24px 64px;
    background: var(--sand);
    text-align: center;
}

.quote-band__ornament {
    margin-bottom: 3px;
    color: var(--gold);
    font-family: var(--serif);
    font-size: 2.8rem;
    line-height: 1;
}

.quote-band blockquote {
    max-width: 810px;
    margin: 0 auto 17px;
    color: var(--wine-deep);
    font-family: var(--serif);
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    font-style: italic;
    line-height: 1.45;
}

.quote-band p {
    margin-bottom: 0;
    color: var(--wine);
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .2em;
}

/* Full timeline and other page sections */
.page-section {
    scroll-margin-top: 85px;
}

.timeline-page {
    padding-top: 104px;
    padding-bottom: 104px;
}

.page-intro {
    max-width: 760px;
    margin-bottom: 34px;
}

.page-intro .eyebrow {
    margin-bottom: 15px;
}

.page-intro h2 {
    margin-bottom: 17px;
}

.page-intro >
p:last-child {
    max-width: 670px;
    margin-bottom: 0;
    color: var(--muted);
    font-size: .92rem;
}

.timeline-controls,
.people-controls {
    display: flex;
    align-items: center;
    gap: 13px;
    margin: 35px 0 10px;
}

.search-field {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 0 15px;
    border: 1px solid var(--line);
    background: var(--paper-bright);
    color: var(--wine);
}

.search-field > span {
    font-size: 1.5rem;
    line-height: 1;
}

.search-field input {
    width: 100%;
    min-width: 0;
    min-height: 47px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: .8rem;
}

.search-field:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(189,150,85,.15);
}

.search-field input:focus-visible {
    outline: 0;
}

.select-field select {
    min-width: 205px;
    min-height: 49px;
    padding: 0 38px 0 14px;
    border: 1px solid var(--line);
    border-radius: 0;
    background: var(--paper-bright);
    color: var(--ink);
    font-size: .77rem;
}

.results-note {
    min-height: 22px;
    margin: 12px 0 19px;
    color: var(--muted);
    font-size: .72rem;
}

.period-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.period-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 255px;
    padding: 22px 22px 20px;
    border: 1px solid var(--line);
    background: var(--paper-bright);
    text-align: left;
    cursor: pointer;
    transition: border-color .2s ease,
        transform .2s ease,
        box-shadow .2s ease;
}

.period-card:hover {
    transform: translateY(-3px);
    border-color: var(--gold);
    box-shadow: 0 12px 25px rgba(56,31,22,.08);
}

.period-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 17px;
}

.period-card__number {
    color: var(--gold);
    font-family: var(--serif);
    font-size: 1.16rem;
}

.period-card__era {
    padding: 4px 7px;
    background: #f0e4d1;
    color: var(--wine);
    font-size: .57rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.period-card__date {
    margin-bottom: 9px;
    color: var(--wine);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.period-card__title {
    margin-bottom: 12px;
    color: var(--wine-deep);
    font-size: 1.25rem;
    line-height: 1.28;
}

.period-card__description {
    margin-bottom: 17px;
    color: var(--muted);
    font-size: .77rem;
    line-height: 1.65;
}

.period-card__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--wine);
    font-size: .69rem;
    font-weight: 700;
}

.period-card__bottom span:last-child {
    font-size: 1rem;
    transition: transform .2s;
}

.period-card:hover
.period-card__bottom span:last-child {
    transform: translateX(4px);
}

.empty-state {
    grid-column: 1 / -1;
    padding: 48px 20px;
    border: 1px dashed var(--line);
    color: var(--muted);
    text-align: center;
}

.people-page {
    padding: 100px 0 105px;
    border-block: 1px solid var(--line);
    background: #f1e7d8;
}

.people-page .page-intro {
    margin-bottom: 30px;
}

.people-page .people-grid {
    margin-top: 17px;
}

.people-page .person-card__portrait {
    min-height: 176px;
}

.people-page .person-card__name {
    font-size: 1.27rem;
}

.resources-page {
    padding-top: 105px;
    padding-bottom: 110px;
}

.resource-note {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    max-width: 780px;
    margin: 31px 0 29px;
    padding: 18px 20px;
    border-left: 3px solid var(--gold);
    background: #eee2ce;
}

.resource-note__icon {
    color: var(--wine);
    font-size: 1.2rem;
}

.resource-note p {
    margin: 0;
    color: #65574b;
    font-size: .78rem;
}

.resource-note strong {
    color: var(--wine-deep);
    font-size: .82rem;
}

.resource-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
}

.resource-card {
    display: flex;
    flex-direction: column;
    min-height: 205px;
    padding: 23px;
    border: 1px solid var(--line);
    background: var(--paper-bright);
    text-decoration: none;
    transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}

.resource-card:hover {
    transform: translateY(-3px);
    border-color: var(--gold);
    box-shadow: 0 12px 25px rgba(56,31,22,.08);
}

.resource-card__type {
    display: inline-flex;
    align-self: flex-start;
    margin-bottom: 15px;
    padding: 4px 8px;
    background: #efe2ce;
    color: var(--wine);
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.resource-card h3 {
    margin-bottom: 10px;
    color: var(--wine-deep);
    font-size: 1.24rem;
    line-height: 1.3;
}

.resource-card p {
    margin-bottom: 17px;
    color: var(--muted);
    font-size: .76rem;
    line-height: 1.6;
}

.resource-card__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    color: var(--wine);
    font-size: .7rem;
    font-weight: 700;
}

/* Footer */
.site-footer {
    background: var(--wine-deep);
    color: #f4e7d9;
}

.site-footer__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 25px;
    padding-top: 37px;
    padding-bottom: 34px;
}

.brand--footer {
    color: var(--gold-light);
}

.brand--footer .brand__name {
    color: #f4e7d9;
}

.brand--footer .brand__tagline {
    color: #ceb4a1;
}

.site-footer__top > p {
    max-width: 320px;
    margin: 0;
    color: #d8c3b5;
    font-size: .77rem;
}

.back-top {
    color: var(--gold-light);
    text-decoration: none;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}
.site-footer__bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 15px max(28px, calc((100vw - var(--content)) / 2));
    border-top: 1px solid rgba(255,255,255,.14);
    color: #bfa99b;
    font-size: .63rem;
}

.footer-colours {
    display: inline-flex;
    gap: 3px;
}

.footer-colours i {
    display: block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #14653f;
}

.footer-colours i:nth-child(2) {
    background: #a92739;
}

.footer-colours i:nth-child(3) {
    background: var(--gold);
}

/* Detail dialog: contents and layouts are deliberately scoped to avoid spilling into navigation or page sections. */

.detail-dialog {
    width: min(760px, calc(100% - 28px));
    max-width: 760px;
    max-height: min(86vh, 850px);
    padding: 0;
    border: 1px solid var(--gold);
    background: var(--paper-bright);
    color: var(--ink);
    box-shadow: 0 28px 80px rgba(23,10,7,.4);
}

.detail-dialog::backdrop {
    background: rgba(35,18,17,.72);
    backdrop-filter: blur(4px);
}

.detail-dialog__bar {
    position: sticky;
    z-index: 2;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 17px 12px 22px;
    border-bottom: 1px solid var(--line);
    background: var(--paper-bright);
}

.detail-dialog__label {
    color: var(--wine);
    font-size: .61rem;
    font-weight: 700;
    letter-spacing: .15em;
}

.dialog-close {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--wine);
    font-size: 1.65rem;
    line-height: 1;
    cursor: pointer;
}

.dialog-close:hover {
    background: var(--wine);
    color: var(--white);
}

.detail-dialog__content {
    padding: clamp(20px, 5vw, 39px);
}

.detail-eyebrow {
    margin-bottom: 9px;
    color: var(--wine);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.detail-title {
    margin-bottom: 10px;
    color: var(--wine-deep);
    font-family: var(--serif);
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.12;
}

.detail-date {
    margin-bottom: 23px;
    color: var(--wine-soft);
    font-size: .83rem;
    font-weight: 700;
}

.detail-lead {
    color: #5d5047;
    font-size: .95rem;
    line-height: 1.85;
}

.detail-subtitle {
    margin: 28px 0 12px;
    color: var(--wine);
    font-family: var(--serif);
    font-size: 1.35rem;
}

.detail-points {
    display: grid;
    gap: 11px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.detail-points li {
    position: relative;
    padding: 0 0 11px 20px;
    border-bottom: 1px solid var(--line);
    color: #5f554d;
    font-size: .83rem;
}

.detail-points li::before {
    position: absolute;
    top: .46em;
    left: 1px;
    width: 7px;
    height: 7px;
    border: 1px solid var(--gold);
    content: ""; transform: rotate(45deg);
}

.detail-events {
    width: 100%;
    border-collapse: collapse;
    margin-top: 13px;
    font-size: .77rem;
}

.detail-events th, .detail-events td {
    padding: 11px 9px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.detail-events th {
    color: var(--wine);
    font-size: .65rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.detail-events td:first-child {
    width: 125px;
    color: var(--wine);
    font-weight: 700;
    white-space: normal;
}

.detail-dialog__profile {
    display: grid;
    grid-template-columns: 155px minmax(0, 1fr);
    align-items: start;
    gap: 24px;
    margin-bottom: 24px;
}

.detail-dialog__portrait {
    display: grid;
    min-height: 170px;
    place-items: center;
    overflow: hidden;
    background: var(--sand);
    color: var(--wine);
}

.detail-dialog__portrait img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    filter: sepia(.16);
}

.detail-dialog__portrait .person-card__initials {
    width: 81px;
    height: 81px;
    font-size: 2rem;
}

.detail-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 11px;
    margin-top: 24px;
}

.detail-fact {
    padding: 12px;
    border: 1px solid var(--line);
    background: #f8f0e4;
}

.detail-fact span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: .59rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.detail-fact strong {
    color: var(--wine);
    font-size: .78rem;
}

.toast {
    position: fixed;
    z-index: 50;
    right: 20px;
    bottom: 20px;
    max-width: min(390px, calc(100% - 40px));
    padding: 12px 16px;
    transform: translateY(20px);
    border: 1px solid var(--gold);
    background: var(--wine-deep);
    color: var(--white);
    font-size: .78rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
}

.toast.is-visible {
    transform: translateY(0);
    opacity: 1;
}



/* Responsive page layouts */
@media (max-width: 1000px) {
  .hero {
    gap: 38px;
  }

  .people-grid--preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .period-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-footer__top {
    flex-wrap: wrap;
  }

  .site-footer__top > p {
    order: 3;
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 720px) {
  html {
    scroll-padding-top: 73px;
  }

  .section-wrap {
    width: min(100% - 36px, var(--content));
  }

  .top-note {
    font-size: .56rem;
    letter-spacing: .08em;
  }

  .site-header {
    min-height: 74px;
    padding: 11px 18px;
  }

  .brand__crest {
    width: 36px;
    height: 42px;
  }

  .brand__name {
    font-size: 1rem;
  }

  .brand__tagline {
    font-size: .49rem;
  }

  .menu-toggle {
    display: block;
  }

  .main-navigation {
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    left: 0;
    display: none;
    align-items: stretch;
    gap: 0;
    padding: 8px 18px 15px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
    box-shadow: 0 12px 18px rgba(56,31,22,.08);
  }

  .main-navigation.is-open {
    display: flex;
    flex-direction: column;
  }

  .nav-link {
    padding: 12px 5px;
  }

  .nav-link::after {
    right: auto;
    bottom: 5px;
    width: 45px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 34px;
    min-height: auto;
    padding-top: 49px;
    padding-bottom: 69px;
  }

  .hero h1 {
    font-size: clamp(3rem, 13vw, 4.6rem);
  }

  .hero__lead {
    font-size: .93rem;
  }

  .hero__footnote {
    margin-top: 29px;
  }

  .hero__visual {
    width: calc(100% - 10px);
    margin-left: 6px;
  }

  .hero__image {
    height: min(75vw, 410px);
  }

  .hero__stamp {
    right: -4px;
    width: 75px;
    height: 75px;
  }

  .hero__stamp strong {
    font-size: 1.3rem;
  }

  .hero__side-label {
    right: -17px;
    bottom: 32px;
    font-size: .48rem;
  }

  .hero__bottom-rule {
    bottom: 29px;
  }

  .intro {
    padding-top: 37px;
    padding-bottom: 65px;
  }

  .intro__body {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .timeline-preview {
    padding-bottom: 70px;
  }

  .section-heading--row {
    align-items: flex-start;
    flex-direction: column;
    gap: 15px;
  }

  .section-heading--row > .text-link {
    margin-bottom: 0;
  }

  .milestone-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .milestone {
    min-height: 155px;
    padding: 20px 12px 20px 0;
  }

  .milestone:not(:first-child) {
    padding-left: 13px;
  }

  .milestone:nth-child(3) {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .milestone:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .feature-band__inner {
    padding-top: 58px;
    padding-bottom: 61px;
  }

  .feature-layout {
    grid-template-columns: 1fr;
    gap: 31px;
  }

  .feature-layout__image-wrap img {
    height: 270px;
  }

  .people-preview {
    padding-top: 68px;
    padding-bottom: 70px;
  }

  .people-grid,
  .people-grid--preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .person-card__portrait {
    min-height: 120px;
  }

  .person-card__body {
    padding: 13px;
  }

  .person-card__name {
    font-size: 1rem;
  }

  .person-card__role {
    font-size: .7rem;
  }

  .quote-band {
    padding: 48px 20px;
  }

  .timeline-page,
  .resources-page {
    padding-top: 67px;
    padding-bottom: 74px;
  }

  .people-page {
    padding: 66px 0 75px;
  }

  .timeline-controls,
  .people-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .select-field select {
    width: 100%;
  }

  .period-grid,
  .resource-grid {
    grid-template-columns: 1fr;
  }

  .period-card {
    min-height: unset;
  }

  .people-page .people-grid {
    margin-top: 12px;
  }

  .people-page .person-card__portrait {
    min-height: 135px;
  }

  .resource-card {
    min-height: 180px;
  }

  .site-footer__top {
    align-items: flex-start;
    flex-direction: column;
    gap: 17px;
    padding-top: 30px;
    padding-bottom: 27px;
  }

  .site-footer__top > p {
    order: 0;
  }

  .site-footer__bottom {
    flex-wrap: wrap;
    justify-content: flex-start;
    padding: 14px 18px;
    font-size: .6rem;
  }

  .site-footer__bottom span:nth-child(2) {
    order: 3;
    width: 100%;
  }

  .detail-dialog__profile {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .detail-dialog__portrait {
    min-height: 190px;
  }

  .detail-dialog__portrait img {
    height: 220px;
  }
}

/* Extra-small screens: main website */
@media (max-width: 420px) {
  .section-wrap {
    width: calc(100% - 28px);
  }

  .hero__actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .people-grid,
  .people-grid--preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .person-card__portrait {
    min-height: 100px;
  }

  .person-card__initials {
    width: 61px;
    height: 61px;
    font-size: 1.45rem;
  }

  .person-card__body {
    padding: 11px;
  }

  .person-card__name {
    font-size: .92rem;
  }

  .person-card__more {
    font-size: .64rem;
  }

  .milestone__date {
    font-size: 1.05rem;
  }

  .milestone__title {
    font-size: .77rem;
  }

  .detail-events th,
  .detail-events td {
    padding: 9px 6px;
    font-size: .68rem;
  }

  .detail-events td:first-child {
    width: 85px;
  }

  .detail-facts {
    grid-template-columns: 1fr;
  }
}

/* Assistant styling must be top-level, not nested in a mobile media rule. */
/* Portugal History AI Assistant */
.history-gpt {
  --chat-wine: #641f32;
  --chat-paper: #fffaf2;
  font-family: var(--sans);
}

.history-gpt__launcher {
  position: fixed;
  z-index: 1000;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 20px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--wine);
  color: var(--paper-bright);
  box-shadow: 0 8px 28px rgba(40, 18, 20, .24);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.history-gpt__launcher:hover {
  background: var(--wine-deep);
}

.history-gpt__icon {
  font-size: 22px;
  line-height: 1;
}

.history-gpt__panel {
  position: fixed;
  z-index: 1001;
  right: 24px;
  bottom: 94px;
  display: flex;
  flex-direction: column;
  width: min(390px, calc(100vw - 28px));
  height: min(560px, calc(100dvh - 125px));
  overflow: hidden;
  border: 1px solid var(--gold);
  background: var(--paper-bright);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(40, 18, 20, .25);
}

.history-gpt__panel[hidden] {
  display: none;
}

.history-gpt__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px;
  background: var(--wine-deep);
  color: var(--paper-bright);
}

.history-gpt__heading {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}

.history-gpt__subtitle {
  margin: 4px 0 0;
  color: #e9d9c8;
  font-size: 11px;
}

.history-gpt__close {
  display: grid;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: transparent;
  color: white;
  font-size: 22px;
  cursor: pointer;
}

.history-gpt__messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  overflow-y: auto;
  padding: 17px;
  overscroll-behavior: contain;
}

.history-gpt__message {
  max-width: 90%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-gpt__message--user {
  align-self: flex-end;
  border-color: var(--wine);
  background: var(--wine);
  color: white;
}

.history-gpt__message--assistant,
.history-gpt__message--status {
  align-self: flex-start;
}

.history-gpt__message--status {
  color: var(--muted);
  font-style: italic;
}

.history-gpt__form {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--paper-bright);
}

.history-gpt__input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.history-gpt__send {
  min-width: 68px;
  padding: 0 13px;
  border: 0;
  background: var(--wine);
  color: white;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.history-gpt__send:disabled {
  cursor: wait;
  opacity: .6;
}

.history-gpt button:focus-visible,
.history-gpt input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}



/* Chat assistant on small screens */
@media (max-width: 480px) {
  .history-gpt__launcher {
    right: 14px;
    bottom: 14px;
  }

  .history-gpt__panel {
    right: 14px;
    bottom: 82px;
    height: min(560px, calc(100dvh - 105px));
  }
}



/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Refined floating assistant layout */
.history-gpt__launcher {
  border-radius: 999px;
  background: var(--wine-deep);
  letter-spacing: .01em;
}
.history-gpt__panel {
  border-radius: 16px;
  max-height: calc(100dvh - 120px);
  min-height: 260px;
}
.history-gpt__header { flex-shrink: 0; }
.history-gpt__heading { line-height: 1.35; }
.history-gpt__messages { min-height: 0; }
.history-gpt__form { flex-shrink: 0; }
.history-gpt__message { border-radius: 12px; }
.history-gpt__input { border-radius: 8px; }
.history-gpt__send { border-radius: 8px; }
@media (max-width: 480px) {
  .history-gpt__launcher { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); }
  .history-gpt__panel {
    width: calc(100vw - 28px);
    right: 14px;
    bottom: calc(82px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 105px - env(safe-area-inset-bottom));
  }
}
