/* =====================================================================
   CORES E LETRAS: muda aqui para mudar o site todo
   ===================================================================== */
:root {
    --blue: #2f5d8a;        /* azul do xadrez, títulos e números */
    --sky: #b9cfe4;         /* azul claro do xadrez e das velharias */
    --sack: #efe6d2;        /* fundo da página (saco de serapilheira) */
    --paper: #fbf7ee;       /* fundo dos cartões */
    --ink: #22303d;         /* texto e contornos */
    --muted: #5b6672;       /* texto secundário */
    --tomato: #d9542f;      /* botões, bilhetes e carimbos */
    --straw: #e9c46a;       /* etiquetas de preço e eventos pontuais */
    --blush: #f3d2c4;       /* artesanato e ilustração */
    --rose: #c4577a;        /* bolinha de artesanato no calendário */

    --font-display: "Alfa Slab One", Georgia, serif;
    --font-type: "Special Elite", "Courier New", monospace;
    --font-body: "Work Sans", system-ui, sans-serif;

    color-scheme: light;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--sack);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
}

a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--tomato); outline-offset: 2px; }

.inner {
    max-width: 1080px;
    margin: 0 auto;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    background: var(--paper);
    border: 2px solid var(--ink);
    padding: 6px 12px;
    z-index: 50;
}
.skip-link:focus { left: 8px; }

/* ---------- Cabeçalho em xadrez ---------- */
.band {
    background-color: var(--sky);
    background-image:
        repeating-linear-gradient(90deg, rgba(47, 93, 138, .5) 0 8px, transparent 8px 30px),
        repeating-linear-gradient(0deg, rgba(47, 93, 138, .5) 0 8px, transparent 8px 30px),
        repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 255, 255, .35) 18px 20px, transparent 20px 30px);
    padding-block: 26px 22px;
}

.band-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    background: var(--sack);
    border: 3px solid var(--ink);
    box-shadow: 5px 5px 0 var(--ink);
    padding: 12px 18px;
    transform: rotate(-1.5deg);
    display: grid;
    gap: 2px;
}
.brand h1 {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--blue);
    margin: 0;
    font-size: clamp(1.6rem, 5vw, 2.5rem);
    line-height: 1;
}
.brand p { margin: 0; font-family: var(--font-type); }

.top-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.top-nav a {
    font-family: var(--font-type);
    text-decoration: none;
    background: var(--paper);
    border: 2px solid var(--ink);
    padding: 6px 12px;
    box-shadow: 3px 3px 0 var(--ink);
    transition: transform .12s, box-shadow .12s;
}
.top-nav a:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }

/* ---------- Faixa que passa ---------- */
.ticker {
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-type);
    overflow: hidden;
    white-space: nowrap;
    padding-block: 7px;
    border-top: 3px solid var(--ink);
}
.ticker:empty, .ticker-track:empty { display: none; }
.ticker-track {
    display: inline-flex;
    gap: 40px;
    padding-left: 100%;
    animation: tick 50s linear infinite;
}
.ticker span::before { content: "✸ "; color: var(--straw); }
@keyframes tick { to { transform: translateX(-100%); } }

/* ---------- Secções ---------- */
main {
    display: grid;
    gap: 44px;
    padding-block: 32px 56px;
}

.sec-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 14px;
}
.sec-head h2 {
    font-family: var(--font-display);
    font-weight: 400;
    margin: 0;
    font-size: clamp(1.3rem, 3.6vw, 1.75rem);
    text-transform: uppercase;
    letter-spacing: .02em;
    text-wrap: balance;
}
.sec-head p { margin: 0; font-family: var(--font-type); color: var(--muted); }

.status-message {
    font-family: var(--font-type);
    background: var(--paper);
    border: 2px dashed var(--ink);
    padding: 12px 16px;
}
.status-message.error { border-color: var(--tomato); color: var(--tomato); }

.empty-note { font-family: var(--font-type); color: var(--muted); }

/* ---------- Avisos ---------- */
.notices { display: grid; gap: 12px; }
.notices-title {
    font-family: var(--font-display);
    font-weight: 400;
    margin: 0;
    font-size: 1.2rem;
    text-transform: uppercase;
}
.notice {
    background: var(--straw);
    border: 3px solid var(--ink);
    padding: 12px 16px;
    display: grid;
    gap: 4px;
}
.notice h3 { margin: 0; font-size: 1.05rem; }
.notice p { margin: 0; }
.notice-date { font-family: var(--font-type); font-size: .85rem; }

/* ---------- Este fim de semana: bilhetes ---------- */
.weekend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 18px;
}
.ticket {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 6px 6px 0 var(--blue);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
}
.ticket-stub {
    background: var(--tomato);
    color: #fff;
    padding: 14px 12px;
    display: grid;
    place-content: center;
    text-align: center;
    border-right: 3px dashed var(--ink);
    min-width: 92px;
}
.ticket-stub .wd { font-family: var(--font-type); font-size: .85rem; text-transform: uppercase; }
.ticket-stub .num { font-family: var(--font-display); font-size: 2.6rem; line-height: 1; }
.ticket-stub .mo { font-family: var(--font-type); font-size: .85rem; }
.ticket ul { list-style: none; margin: 0; padding: 12px 14px; display: grid; gap: 10px; align-content: start; }
.ticket li button {
    all: unset;
    cursor: pointer;
    display: grid;
    gap: 1px;
}
.ticket li button:focus-visible { outline: 3px solid var(--tomato); outline-offset: 2px; }
.ticket li b { font-size: 1rem; }
.ticket li button:hover b { text-decoration: underline; text-decoration-color: var(--tomato); text-decoration-thickness: 2px; }
.ticket li span { font-family: var(--font-type); font-size: .85rem; color: var(--muted); }

.stamp {
    display: inline-block;
    font-family: var(--font-type);
    font-size: .72rem;
    font-weight: 400;
    border: 2px solid var(--tomato);
    color: var(--tomato);
    padding: 0 6px;
    transform: rotate(-4deg);
    margin-left: 6px;
    vertical-align: 2px;
}

/* ---------- Próximos mercados ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters button {
    font: inherit;
    font-family: var(--font-type);
    cursor: pointer;
    background: var(--paper);
    color: var(--ink);
    border: 2px solid var(--ink);
    padding: 6px 12px;
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.upcoming {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.event-card {
    background: var(--paper);
    border: 3px solid var(--ink);
    padding: 14px;
    display: grid;
    gap: 8px;
    align-content: start;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 0 0 var(--ink);
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    width: 100%;
    height: 100%;
}
.event-card:hover { transform: translate(-2px, -2px) rotate(-.4deg); box-shadow: 5px 5px 0 var(--ink); }
.event-card .when { display: flex; align-items: center; gap: 10px; }
.event-card .dnum {
    font-family: var(--font-display);
    font-size: 1.7rem;
    line-height: 1;
    color: var(--blue);
    font-variant-numeric: tabular-nums;
}
.event-card .dtxt { font-family: var(--font-type); font-size: .82rem; line-height: 1.2; }
.event-card h3 { margin: 0; font-size: 1.05rem; }
.event-card .place { font-size: .88rem; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--font-type); font-size: .72rem; padding: 1px 7px; border: 1.5px solid var(--ink); }
.tag.velharias { background: var(--sky); }
.tag.artesanato { background: var(--blush); }
.tag.pontual { background: var(--straw); }
.tag.rule { background: transparent; border-style: dashed; }

.more { margin-top: 14px; font-family: var(--font-type); }
.link-btn {
    font: inherit;
    font-family: var(--font-type);
    cursor: pointer;
    background: none;
    border: 0;
    border-bottom: 2px solid var(--tomato);
    color: var(--ink);
    padding: 0;
}

/* ---------- Todos os meses: etiquetas de preço ---------- */
.recurring-groups { display: grid; gap: 22px; }
.recurring-group h3 {
    font-family: var(--font-type);
    font-weight: 400;
    font-size: 1rem;
    margin: 0 0 10px;
    color: var(--blue);
}
.recurring {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 14px;
    list-style: none;
    padding: 0;
    margin: 0;
}
.price-tag {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--straw);
    padding: 12px 14px 12px 32px;
    clip-path: polygon(16px 0, 100% 0, 100% 100%, 16px 100%, 0 50%);
    display: grid;
    gap: 2px;
    align-content: start;
    transition: background .15s;
}
.price-tag::before {
    content: "";
    position: absolute;
    left: 14px;
    top: 50%;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-radius: 50%;
    background: var(--sack);
    box-shadow: inset 0 0 0 2px var(--ink);
}
.price-tag:hover { background: #f0d28a; }
.price-tag:focus-visible { outline: 3px solid var(--tomato); outline-offset: -3px; }
.price-tag b { font-size: .98rem; }
.price-tag span { font-family: var(--font-type); font-size: .82rem; }

/* ---------- Calendário ---------- */
.cal-box { background: var(--paper); border: 3px solid var(--ink); padding: 16px; }
.monthbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.month-title { display: grid; justify-items: center; gap: 2px; }
.month-title h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: .03em;
    text-align: center;
}
.nav-btn {
    font: inherit;
    font-family: var(--font-type);
    background: var(--sack);
    border: 2px solid var(--ink);
    cursor: pointer;
    padding: 4px 12px;
    color: var(--ink);
}
.weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.weekdays span { text-align: center; font-family: var(--font-type); font-size: .75rem; color: var(--blue); }
.cal-day {
    all: unset;
    box-sizing: border-box;
    min-height: 54px;
    border-top: 2px solid var(--ink);
    padding: 3px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.cal-day.has-events { cursor: pointer; }
.cal-day.has-events:hover { background: var(--sack); }
.cal-day:focus-visible { outline: 3px solid var(--tomato); outline-offset: -3px; }
.cal-day.past { opacity: .45; }
.cal-day.other-month { visibility: hidden; }
.cal-day.selected { background: var(--sky); }
.cal-day .n { font-size: .8rem; font-variant-numeric: tabular-nums; }
.cal-day.today .n {
    background: var(--tomato);
    color: #fff;
    border-radius: 50%;
    width: 1.7em;
    height: 1.7em;
    display: grid;
    place-items: center;
}
.dots { display: flex; flex-wrap: wrap; gap: 3px; }
.dot { display: inline-block; width: 11px; height: 11px; border: 1.5px solid var(--ink); border-radius: 50%; }
.dot.velharias { background: var(--blue); }
.dot.artesanato { background: var(--rose); }
.dot.pontual { background: var(--straw); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--font-type); font-size: .8rem; margin-top: 12px; }
.legend .dot { margin-right: 5px; vertical-align: -1px; }

.day-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.day-list:empty { display: none; }
.day-list .day-list-title { font-family: var(--font-type); color: var(--muted); }
.day-list button {
    all: unset;
    cursor: pointer;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    align-items: baseline;
    border-left: 4px solid var(--tomato);
    padding-left: 10px;
}
.day-list button:focus-visible { outline: 3px solid var(--tomato); outline-offset: 2px; }
.day-list button:hover b { text-decoration: underline; }
.day-list span { font-family: var(--font-type); font-size: .85rem; color: var(--muted); }

/* ---------- Sugestões ---------- */
.suggest {
    background: var(--blue);
    color: var(--paper);
    border: 3px solid var(--ink);
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    box-shadow: 6px 6px 0 var(--ink);
}
.suggest h2 { font-family: var(--font-display); font-weight: 400; margin: 0 0 4px; font-size: 1.3rem; }
.suggest p { margin: 0; max-width: 52ch; }

.btn {
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    background: var(--tomato);
    color: #fff;
    border: 3px solid var(--ink);
    padding: 9px 16px;
    display: inline-block;
    cursor: pointer;
    justify-self: start;
}
.btn:hover { background: #c4461f; }

/* ---------- Rodapé ---------- */
.site-footer { border-top: 3px solid var(--ink); padding-block: 18px 28px; font-family: var(--font-type); font-size: .85rem; color: var(--muted); }
.site-footer p { margin: 0; }

/* ---------- Pop-up ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(34, 48, 61, .55);
    display: grid;
    place-items: center;
    padding: 16px;
    z-index: 20;
}
.modal-card {
    background: var(--paper);
    border: 3px solid var(--ink);
    box-shadow: 8px 8px 0 var(--blue);
    max-width: 460px;
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 22px;
    display: grid;
    gap: 10px;
    position: relative;
}
.modal-card h2 { font-family: var(--font-display); font-weight: 400; margin: 0; font-size: 1.45rem; padding-right: 30px; text-wrap: balance; }
.modal-details { font-family: var(--font-type); display: grid; gap: 2px; }
.modal-details a { text-decoration-color: var(--tomato); text-decoration-thickness: 2px; }
.modal-description { margin: 0; }
.close-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    font: inherit;
    font-size: 1.6rem;
    line-height: 1;
    background: none;
    border: 0;
    cursor: pointer;
    color: var(--ink);
}
body.modal-open { overflow: hidden; }

/* ---------- Telemóvel ---------- */
@media (max-width: 520px) {
    .cal-day { min-height: 42px; }
    .cal-box { padding: 12px; }
    .top-nav a { padding: 5px 10px; font-size: .9rem; }
}

/* ---------- Menos movimento para quem pede ---------- */
@media (prefers-reduced-motion: reduce) {
    .ticker-track { animation: none; padding-left: 16px; }
    .event-card, .top-nav a, .price-tag { transition: none; }
    .event-card:hover { transform: none; }
}

/* =====================================================================
   ACABAMENTOS: toldo, tecido, costuras e letra à mão
   ===================================================================== */
:root {
    --cherry: #c8323c;      /* riscas do toldo e letra à mão */
    --font-hand: "Caveat", "Comic Sans MS", cursive;
}

/* Fundo com textura de linho */
body {
    background-color: var(--sack);
    background-image:
        repeating-linear-gradient(0deg, rgba(120, 95, 60, .045) 0 1px, transparent 1px 4px),
        repeating-linear-gradient(90deg, rgba(120, 95, 60, .04) 0 1px, transparent 1px 5px);
}

/* Faixa no topo da página */
.ticker { border-top: 0; font-size: .9rem; }

/* Cabeçalho: etiqueta maior, com letra à mão por cima */
.band { padding-block: 34px 30px; }
.brand { padding: 14px 22px 16px; box-shadow: 6px 6px 0 var(--ink); }
.brand-kicker {
    font-family: var(--font-hand);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--cherry);
    line-height: 1;
    transform: rotate(-3deg);
    justify-self: start;
    margin-bottom: 2px;
}
.top-nav a { border-radius: 999px; padding: 6px 14px; }

/* Toldo às riscas com bainha recortada */
.awning {
    height: 42px;
    background: repeating-linear-gradient(90deg, var(--cherry) 0 34px, var(--paper) 34px 68px);
    -webkit-mask:
        radial-gradient(circle 17px at 50% 24px, #000 96%, transparent 100%) 0 0 / 34px 100% repeat-x,
        linear-gradient(#000, #000) 0 0 / 100% 24px no-repeat;
    mask:
        radial-gradient(circle 17px at 50% 24px, #000 96%, transparent 100%) 0 0 / 34px 100% repeat-x,
        linear-gradient(#000, #000) 0 0 / 100% 24px no-repeat;
    filter: drop-shadow(0 3px 0 rgba(34, 48, 61, .25));
    margin-bottom: -14px;
    position: relative;
    z-index: 1;
}

/* Títulos: letra à mão por cima e fita de xadrez por baixo */
.sec-head h2 { display: grid; gap: 0; }
.sec-head h2 .kicker {
    font-family: var(--font-hand);
    font-weight: 700;
    font-size: 1.3rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--cherry);
    line-height: 1;
    transform: rotate(-2deg);
    transform-origin: left;
    justify-self: start;
}
.sec-head h2::after {
    content: "";
    display: block;
    width: 72px;
    height: 8px;
    margin-top: 8px;
    background-color: var(--paper);
    background-image:
        linear-gradient(90deg, rgba(200, 50, 60, .55) 50%, transparent 50%),
        linear-gradient(rgba(200, 50, 60, .55) 50%, transparent 50%);
    background-size: 8px 8px;
    border-radius: 2px;
}

/* Costuras: contorno tracejado por dentro dos cartões */
.ticket, .event-card, .cal-box, .suggest, .notice {
    border-width: 2px;
    border-radius: 6px;
    outline: 1.5px dashed rgba(34, 48, 61, .28);
    outline-offset: -8px;
}
.ticket { overflow: hidden; }
.ticket-stub { border-right: 2px dashed var(--paper); }
.suggest { outline-color: rgba(251, 247, 238, .45); }
.event-card:focus-visible { outline: 3px solid var(--tomato); outline-offset: 2px; }

/* Cartões ligeiramente tortos, como papéis presos numa banca */
.upcoming li:nth-child(3n+1) .event-card { transform: rotate(-.6deg); }
.upcoming li:nth-child(3n+2) .event-card { transform: rotate(.4deg); }
.event-card { box-shadow: 4px 4px 0 rgba(47, 93, 138, .35); }
.event-card:hover { transform: translateY(-3px) rotate(0deg) !important; box-shadow: 6px 7px 0 var(--blue); }

/* Filtros como etiquetas redondas */
.filters button { border-radius: 999px; padding: 6px 14px; }

/* Etiquetas de preço com um fio */
.price-tag { border-radius: 0 6px 6px 0; }
.price-tag:hover { transform: rotate(-1deg); }

/* Rodapé com xadrez */
.site-footer {
    border-top: 0;
    padding-top: 26px;
    background:
        linear-gradient(var(--sack), var(--sack)) 0 14px / 100% 100% no-repeat,
        repeating-linear-gradient(90deg, rgba(47, 93, 138, .5) 0 7px, transparent 7px 20px),
        var(--sky);
}

@media (prefers-reduced-motion: reduce) {
    .upcoming li .event-card, .event-card:hover, .price-tag:hover { transform: none !important; }
}
