@font-face {
  font-family: 'Vollkorn';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(vollkorn-var.woff2) format('woff2');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url(manrope-var.woff2) format('woff2');
}
@font-face {
  font-family: 'Noto Color Emoji';
  font-style: normal;
  font-display: swap;
  src: url(NotoColorEmoji.woff2) format('woff2');
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F7F6F3;
  --bg-card: #FFFFFF;
  --text: #2C1810;
  --text-secondary: #6B5744;
  --text-muted: #857161;
  --border: #E8E5E0;
  --border-light: #F0EDEA;
  --shadow-sm: 0 1px 3px rgba(44, 24, 16, 0.05);
  --shadow: 0 2px 8px rgba(44, 24, 16, 0.07);
  --shadow-hover: 0 6px 20px rgba(44, 24, 16, 0.1);
  --sunflower: #D4941F;
  --sunflower-light: #EDB83A;
}

body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body::before {
  content: '';
  display: block;
  height: 3px;
  flex-shrink: 0;
  background: linear-gradient(90deg, var(--sunflower), var(--sunflower-light), var(--sunflower));
}

header {
  padding: 0.625rem 1rem;
  padding-left: calc(env(safe-area-inset-left, 0px) + 1rem);
  padding-right: calc(env(safe-area-inset-right, 0px) + 1rem);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  height: 2rem;
  width: auto;
  max-width: 30%;
}

.header-titles {
  flex: 1;
  text-align: center;
  min-width: 0;
}

h1 {
  font-family: 'Vollkorn', Georgia, serif;
  font-size: 1.0625rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1.2;
}

.subtitle {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.5rem;
  border-radius: 999rem;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  white-space: nowrap;
}

.status-open { background: #E8F5E9; color: #2E7D32; }
.status-open::before {
  content: '';
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: #2E7D32;
  animation: pulse 2s ease-in-out infinite;
}
.status-closed { background: #EDEAE6; color: var(--text-secondary); }
.status-weekend { background: #E8EAF6; color: #3949AB; }
.status-holiday { background: #FFF8E1; color: #E65100; }

main {
  flex: 1;
  padding: 0.5rem;
  padding-left: calc(env(safe-area-inset-left, 0px) + 0.5rem);
  padding-right: calc(env(safe-area-inset-right, 0px) + 0.5rem);
  min-height: 0;
  display: flex;
  align-items: flex-start;
}

.grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 80rem;
}

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-left: 3px solid var(--text-muted);
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 0.1875rem;
  box-shadow: var(--shadow-sm);
  animation: cardIn 0.4s ease both;
}

.card:nth-child(1) { animation-delay: 0.04s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.16s; }
.card:nth-child(4) { animation-delay: 0.22s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(0.375rem); }
  to { opacity: 1; transform: translateY(0); }
}

.accent-wheat { border-left-color: #b45309; }
.accent-corn { border-left-color: #ca8a04; }
.accent-milo { border-left-color: #65a30d; }
.accent-soy { border-left-color: #0d9488; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.commodity-name {
  font-family: 'Vollkorn', Georgia, serif;
  font-size: clamp(0.75rem, 1vw + 0.5rem, 1rem);
  font-weight: 700;
  color: var(--text-secondary);
}

.card-emoji {
  position: absolute;
  bottom: 0.25rem;
  right: 0.375rem;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  font-style: normal;
  font-size: clamp(1rem, 2vw + 0.5rem, 2rem);
  opacity: 0.8;
  line-height: 1;
  pointer-events: none;
}

.change {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 0.0625rem 0.375rem;
  border-radius: 0.25rem;
}

.change.up { background: #E8F5E9; color: #2E7D32; }
.change.down { background: #FFEBEE; color: #C62828; }
.change.flat { background: #EDEAE6; color: var(--text-muted); }

.card-body {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
}

.price {
  font-size: clamp(1.5rem, 3vw + 0.5rem, 2.5rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.price.no-data {
  color: var(--border);
}

.price-label {
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.spark-section {
  flex-shrink: 0;
}

.spark-section + .spark-section {
  margin-top: 0.1875rem;
  padding-top: 0.1875rem;
  border-top: 1px solid var(--border-light);
}

.spark-label {
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sparkline {
  width: 100%;
  height: 1.375rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.refresh-dot {
  display: inline-block;
  width: 0.3125rem;
  height: 0.3125rem;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 3s ease-in-out infinite;
  vertical-align: middle;
  margin-right: 0.1875rem;
}

footer {
  padding: 0.375rem 1rem;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 0.375rem);
  padding-left: calc(env(safe-area-inset-left, 0px) + 1rem);
  padding-right: calc(env(safe-area-inset-right, 0px) + 1rem);
  border-top: 1px solid var(--border);
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
  max-width: 80rem;
}

@media (max-width: 30rem) {
  body { height: auto; overflow: auto; }
  .grid { grid-template-columns: 1fr; }
  main { align-items: flex-start; }
}

@media (max-height: 30rem) {
  body { height: auto; overflow: auto; }
}

@media (min-width: 30rem) {
  header { padding: 0.75rem 1.25rem; padding-left: calc(env(safe-area-inset-left, 0px) + 1.25rem); padding-right: calc(env(safe-area-inset-right, 0px) + 1.25rem); }
  h1 { font-size: 1.375rem; }
  .subtitle { font-size: 0.6875rem; }
  .logo { height: 2.5rem; }
  main { padding: 0.75rem; padding-left: calc(env(safe-area-inset-left, 0px) + 0.75rem); padding-right: calc(env(safe-area-inset-right, 0px) + 0.75rem); }
  .grid { gap: 0.75rem; }
  .card { padding: 0.75rem 1rem; gap: 0.25rem; border-left-width: 4px; }
  .sparkline { height: 1.75rem; }
  .spark-label { font-size: 0.625rem; }
  .price-label { font-size: 0.625rem; }
  footer { font-size: 0.6875rem; }
}

@media (min-width: 64rem) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

@media (hover: hover) {
  .card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
  }
}

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