:root {
  --paper: #f1ede3;
  --paper-light: #faf8f2;
  --ink: #171713;
  --muted: #6d6a61;
  --red: #e6442f;
  --green: #175d50;
  --blue: #4d5fc1;
  --yellow: #e7ba3f;
  --line: rgba(23, 23, 19, 0.2);
  --display: "Archivo Black", Impact, sans-serif;
  --body: "DM Sans", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    linear-gradient(rgba(23, 23, 19, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 8px;
  color: var(--ink);
  font-family: var(--body);
  text-rendering: optimizeLegibility;
}

button, a { font: inherit; }

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

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

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

.page-shell {
  width: min(1440px, calc(100% - 36px));
  margin: 18px auto;
  border: 1px solid var(--ink);
  background: var(--paper);
  box-shadow: 10px 10px 0 var(--ink);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  border-bottom: 1px solid var(--ink);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: -0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.wordmark-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  background: var(--red);
  color: white;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  font-size: 0.8rem;
  padding-top: 9px;
}

.header-meta {
  display: flex;
  align-items: center;
  align-self: stretch;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-meta > span { padding: 0 24px; }

.refresh-button {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 100%;
  border: 0;
  border-left: 1px solid var(--ink);
  border-radius: 0;
  padding: 0 24px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 160ms ease, color 160ms ease;
}

.refresh-button svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: square;
  stroke-width: 1.8;
  transition: transform 400ms ease;
}

.refresh-button:hover { background: var(--ink); color: white; }
.refresh-button:hover svg { transform: rotate(180deg); }
.refresh-button:focus-visible { outline: 3px solid var(--blue); outline-offset: -4px; }
.refresh-button:disabled { cursor: wait; opacity: 0.6; }
.refresh-button:disabled svg { animation: rotate 900ms linear infinite; }

.hero {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  padding: clamp(62px, 9vw, 126px) clamp(24px, 6vw, 88px) 64px;
  border-bottom: 1px solid var(--ink);
}

.hero::before {
  position: absolute;
  right: -4%;
  bottom: -36%;
  width: clamp(300px, 44vw, 650px);
  aspect-ratio: 1;
  border: 1px solid var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 0 0 40px var(--paper), inset 0 0 0 41px var(--ink), inset 0 0 0 90px var(--paper), inset 0 0 0 91px var(--ink);
  content: "";
}

.hero::after {
  position: absolute;
  right: 8%;
  bottom: 8%;
  width: 76px;
  height: 76px;
  background: var(--red);
  content: "";
  transform: rotate(45deg);
}

.hero-kicker {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

h1 {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin-bottom: 28px;
  font-family: var(--display);
  font-size: clamp(3.3rem, 8.5vw, 8.2rem);
  font-weight: 400;
  letter-spacing: -0.075em;
  line-height: 0.86;
  text-transform: uppercase;
}

h1 em { color: var(--red); font-style: normal; }

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 540px;
  margin: 0;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.55;
}

.hero-rule {
  position: absolute;
  bottom: 29px;
  left: clamp(24px, 6vw, 88px);
  width: 180px;
  height: 6px;
  background: var(--ink);
}

.hero-rule span { display: block; width: 32%; height: 100%; background: var(--yellow); }

.weather-section, .stocks-section { padding: clamp(46px, 7vw, 90px) clamp(20px, 5vw, 72px); }

.section-heading {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: end;
  gap: 22px;
  margin-bottom: 34px;
}

.section-index {
  color: var(--red);
  font-family: var(--display);
  font-size: 1rem;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 4.5vw, 4.1rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.95;
  text-transform: uppercase;
}

.section-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: right;
  text-transform: uppercase;
}

.weather-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--ink);
  border-left: 1px solid var(--ink);
}

.weather-card {
  min-width: 0;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: var(--paper-light);
  animation: rise 500ms ease both;
}

.weather-card:nth-child(2) { animation-delay: 80ms; }
.weather-card:nth-child(3) { animation-delay: 160ms; }

.city-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  min-height: 138px;
  padding: 24px;
  border-bottom: 1px solid var(--ink);
}

.weather-card[data-city="basel"] .city-head { background: var(--red); color: white; }
.weather-card[data-city="lugano"] .city-head { background: var(--yellow); }
.weather-card[data-city="klosters-serneus"] .city-head { background: var(--green); color: white; }

.city-number {
  display: block;
  margin-bottom: 22px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  opacity: 0.75;
  text-transform: uppercase;
}

.city-head h3 {
  margin-bottom: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  font-weight: 400;
  letter-spacing: -0.05em;
  line-height: 0.98;
  text-transform: uppercase;
}

.city-outlook { align-self: end; text-align: right; }
.city-outlook strong { display: block; font-family: var(--display); font-size: 2.15rem; font-weight: 400; letter-spacing: -0.06em; }
.city-outlook span { font-size: 0.67rem; letter-spacing: 0.08em; opacity: 0.75; text-transform: uppercase; }

.weather-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.weather-table th, .weather-table td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: right; }
.weather-table th { color: var(--muted); font-size: 0.65rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; }
.weather-table th:first-child, .weather-table td:first-child { padding-left: 20px; text-align: left; }
.weather-table th:last-child, .weather-table td:last-child { padding-right: 20px; }
.weather-table td { font-size: 0.88rem; }
.weather-table td:first-child { font-weight: 600; text-transform: capitalize; }
.weather-table tbody tr:last-child td { border-bottom: 0; }
.weather-table tbody tr:hover { background: rgba(23, 23, 19, 0.055); }
.precip-cell { color: var(--blue); }

.loading-card { min-height: 512px; padding: 24px; }
.loading-card::before, .loading-card::after, .loading-line {
  display: block;
  background: linear-gradient(90deg, rgba(23,23,19,.08), rgba(255,255,255,.65), rgba(23,23,19,.08));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  content: "";
}
.loading-card::before { width: 58%; height: 30px; margin: 18px 0 70px; }
.loading-card::after { width: 100%; height: 290px; }
.error-card { display: grid; min-height: 360px; place-items: center; padding: 30px; text-align: center; }
.error-card strong { display: block; margin-bottom: 8px; font-family: var(--display); text-transform: uppercase; }
.error-card p { max-width: 260px; margin: 0; color: var(--muted); font-size: 0.86rem; }

.stocks-section { background: var(--ink); color: var(--paper-light); }
.section-heading-dark .section-index { color: var(--yellow); }
.section-heading-dark .eyebrow, .section-heading-dark .section-note { color: rgba(250, 248, 242, 0.58); }

.chart-panel { border: 1px solid rgba(250, 248, 242, 0.35); }
.chart-topline {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  min-height: 112px;
  padding: 24px 28px;
  border-bottom: 1px solid rgba(250, 248, 242, 0.35);
}
.chart-label { margin-bottom: 8px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.status { margin-bottom: 0; color: rgba(250, 248, 242, 0.58); font-size: 0.84rem; }
.status.error { color: #ff8c7a; }
.stock-legend { display: grid; grid-template-columns: repeat(3, minmax(135px, 1fr)); gap: 12px 18px; }
.legend-item { min-width: 0; padding-left: 12px; border-left: 4px solid var(--series-color); }
.legend-item span { display: block; color: rgba(250, 248, 242, 0.6); font-size: 0.66rem; letter-spacing: 0.05em; text-transform: uppercase; }
.legend-item strong { font-family: var(--display); font-size: 1.15rem; font-weight: 400; }
.legend-item strong.positive::before { content: "+"; }
.chart-wrap { position: relative; height: min(520px, 55vw); min-height: 350px; padding: 24px 20px 16px; }
.chart-wrap canvas { opacity: 0; transition: opacity 300ms ease; }
.chart-wrap.is-ready canvas { opacity: 1; }
.chart-skeleton { position: absolute; inset: 40px 32px 50px 50px; display: flex; align-items: end; gap: 7%; }
.chart-skeleton::before { position: absolute; inset: 0; background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), rgba(255,255,255,.1) 25%); content: ""; }
.chart-skeleton span { z-index: 1; width: 18%; background: rgba(255,255,255,.09); animation: pulse 1.3s ease-in-out infinite alternate; }
.chart-skeleton span:nth-child(1) { height: 42%; }
.chart-skeleton span:nth-child(2) { height: 68%; animation-delay: 120ms; }
.chart-skeleton span:nth-child(3) { height: 52%; animation-delay: 240ms; }
.chart-skeleton span:nth-child(4) { height: 78%; animation-delay: 360ms; }
.chart-wrap.is-ready .chart-skeleton { display: none; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  padding: 25px 28px;
  border-top: 1px solid var(--ink);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}
.site-footer p { max-width: 660px; margin: 0; text-align: right; }
.footer-label { margin-right: 12px; color: var(--ink); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rotate { to { transform: rotate(360deg); } }
@keyframes pulse { to { opacity: 0.35; } }

@media (max-width: 1020px) {
  .weather-grid { grid-template-columns: 1fr; }
  .loading-card { min-height: 260px; }
  .chart-topline { flex-direction: column; }
  .stock-legend { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .page-shell { width: calc(100% - 16px); margin: 8px auto; box-shadow: 5px 5px 0 var(--ink); }
  .site-header { min-height: 58px; }
  .wordmark { padding: 0 14px; font-size: 0.88rem; }
  .wordmark-mark { width: 28px; height: 28px; padding-top: 8px; }
  .header-meta > span { display: none; }
  .refresh-button { padding: 0 14px; font-size: 0.68rem; }
  .hero { min-height: 430px; padding-top: 74px; }
  .hero::before { right: -30%; bottom: -22%; }
  .hero::after { right: 7%; width: 48px; height: 48px; }
  .hero-kicker { gap: 12px; font-size: 0.58rem; }
  h1 { font-size: clamp(3rem, 16vw, 5.4rem); }
  .section-heading { grid-template-columns: 34px 1fr; gap: 12px; }
  .section-note { display: none; }
  .weather-section, .stocks-section { padding: 48px 14px; }
  .city-head { min-height: 124px; padding: 20px; }
  .chart-topline { padding: 20px; }
  .stock-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-wrap { height: 420px; padding: 16px 6px 10px; }
  .site-footer { flex-direction: column; padding: 20px; }
  .site-footer p { text-align: left; }
}

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