@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,wght@1,400;1,600&display=swap');

:root {
    --bg: #eaf5ee;
    --bg-gradient-top: #7cb8e0;
    --bg-gradient-bottom: #eaf5ee;
    --accent-green: #5da570;
    --accent-green-soft: #9ccba6;
    --text: #2d3e50;
    --heading: #1a2b3c;
    --muted: #6b7f92;
    --surface: rgba(255,255,255,0.55);
    --surface-2: rgba(255,255,255,0.75);
    --border: rgba(255,255,255,0.7);
    --border-soft: rgba(120, 160, 200, 0.18);
    --accent: #4a90c2;
    --accent-soft: #7cb8e0;
    --white: #ffffff;
    --transition: 0.2s ease;
    --radius: 18px;
    --shadow-soft: 0 8px 32px rgba(120, 160, 200, 0.15);
    --shadow-hover: 0 12px 40px rgba(74, 144, 194, 0.2);
}

/* -------------------- BASE -------------------- */

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

html { scroll-behavior: smooth; }

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    padding-bottom: 80px; /* keep content clear of the grass strip */
}

h1, h2, h3, h4 {
    color: var(--heading);
    letter-spacing: -0.02em;
}

h1 {
    font-family: 'Newsreader', serif;
    font-style: italic;
}

p { color: var(--text); }

a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity var(--transition);
}
a:hover { opacity: 0.75; }

/* -------------------- BACKGROUND -------------------- */

.background {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 130% 45% at 50% 108%, rgba(125, 180, 130, 0.35) 0%, transparent 70%),
        linear-gradient(180deg, #7cb8e0 0%, #a8d0e8 35%, #d8ebf5 60%, #dceee2 82%, #e4f2e6 100%);
    overflow: hidden;
}

/* Soft cloud-like glow */
.background::before {
    content: '';
    position: absolute;
    top: 10%;
    left: -10%;
    width: 60%;
    height: 40%;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.6) 0%, transparent 70%);
    filter: blur(40px);
    pointer-events: none;
}

.background::after {
    content: '';
    position: absolute;
    top: 30%;
    right: -5%;
    width: 50%;
    height: 30%;
    background: radial-gradient(ellipse at center, rgba(255,255,255,0.5) 0%, transparent 70%);
    filter: blur(50px);
    pointer-events: none;
}

/* Realistic drifting clouds — blobs of stacked box-shadows, edges
   roughened by the #cloud-fluff SVG turbulence filter (injected by script.js) */
.background .cloud {
    position: absolute;
    left: 0;
    width: 220px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    box-shadow:
        -70px 12px 30px 6px rgba(255,255,255,0.75),
        80px -12px 34px 10px rgba(255,255,255,0.9),
        30px 14px 36px 8px rgba(255,255,255,0.8),
        -20px -26px 28px 2px rgba(255,255,255,0.95),
        60px 22px 30px 4px rgba(250,253,255,0.7),
        0 34px 26px -14px rgba(150,175,200,0.4);
    filter: url(#cloud-fluff);
    animation: cloud-drift linear infinite;
    will-change: transform;
}

.background .cloud-1 { top: 8%;  --cloud-scale: 1.15; animation-duration: 210s; animation-delay: -80s; }
.background .cloud-2 { top: 24%; --cloud-scale: 0.75; opacity: 0.85; animation-duration: 260s; animation-delay: -180s; }
.background .cloud-3 { top: 14%; --cloud-scale: 1.5;  opacity: 0.95; animation-duration: 300s; animation-delay: -40s; }
.background .cloud-4 { top: 36%; --cloud-scale: 0.55; opacity: 0.6;  animation-duration: 320s; animation-delay: -240s; }

/* MOBILE: script.js tags clouds .cloud-simple and skips injecting #cloud-fluff.
   Without this rule the clouds still reference the missing filter and get
   hidden (Chromium treats an unresolved filter url() as display:none). */
.background .cloud-simple { filter: none; }

@keyframes cloud-drift {
    from { transform: translateX(-45vw) scale(var(--cloud-scale, 1)); }
    to   { transform: translateX(120vw) scale(var(--cloud-scale, 1)); }
}

/* Swaying grass strip along the bottom edge (blades generated by script.js) */
.grass {
    position: fixed;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 70px;
    z-index: 50;
    pointer-events: none;
}

@keyframes blade-sway {
    from { transform: rotate(-2.4deg); }
    to   { transform: rotate(3.2deg); }
}

@media (prefers-reduced-motion: reduce) {
    .grass path { animation: none !important; }
}

/* -------------------- LAYOUT -------------------- */

.container {
    max-width: 820px;
    margin: auto;
    padding: 80px 24px;
}

.hero { margin-bottom: 60px; text-align: center; }

.hero h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 1.1;
    background: linear-gradient(135deg, #5da570 0%, #0c1927 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 20px rgba(255,255,255,0.3);
}

.subtitle {
    margin-top: 12px;
    color: var(--muted);
    font-size: 1.05rem;
}

.subtitle-detail {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

/* -------------------- COW GALLERY -------------------- */

.cow-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-bottom: 60px;
}

.cow-info-card {
    padding: 26px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    box-shadow: var(--shadow-soft);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.cow-info-card:hover {
    transform: translateY(-3px);
    background: var(--surface-2);
    border-color: rgba(93, 165, 112, 0.4);
    box-shadow: var(--shadow-hover);
}

.cow-info-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.cow-info-card h2 {
    margin-top: 10px;
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.cow-info-card p {
    color: var(--muted);
    margin-bottom: 0;
}

.cow-info-card a {
    color: var(--accent);
}

/* -------------------- FOOTER -------------------- */

.hill-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding-top: 20px;
}

/* -------------------- COW PETS -------------------- */

.cow-pen {
    position: fixed;
    left: 0;
    bottom: 6px;
    width: 100%;
    height: 70px;
    z-index: 51;
    pointer-events: none;
    overflow: visible;
}

.cow-anchor {
    position: absolute;
    bottom: 0;
    width: 92px;
    transform: translateX(-50%) scale(var(--cow-scale, 1));
    transform-origin: bottom center;
}

.cow {
    cursor: grab;
    pointer-events: auto;
    animation: cow-walk 14s ease-in-out infinite;
    will-change: transform;
}

.cow:active { cursor: grabbing; }

.cow-svg {
    width: 100%;
    display: block;
    overflow: visible;
    transform-origin: 50% 100%;
}

.cow-svg.is-patted { animation: cow-pat-wiggle 480ms ease-in-out; }

/* Everything below the master cow-walk timeline runs on the SAME duration +
   negative delay (set inline by script.js on .cow and every .cow-sync element),
   so all keyframe percentages here line up with cow-walk's phases:
   walk 0–28, graze 28–46, turn 46–50, walk 50–78, graze 78–96, turn 96–100.
   cow-gait-a/b, cow-body-bob and cow-chew are generated + injected by
   script.js from those same window percentages. */

.cow-walkbody {
    animation: cow-body-bob 14s ease-in-out infinite;
}

.cow-head {
    transform-origin: 30px 26px;
    animation: cow-head-bob 14s ease-in-out infinite;
}

.cow-leg {
    transform-box: fill-box;
    transform-origin: 50% 6%; /* swing from the hip */
}
.cow-leg-a { animation: cow-gait-a 14s ease-in-out infinite; }
.cow-leg-b { animation: cow-gait-b 14s ease-in-out infinite; }

.cow-tail {
    transform-box: fill-box;
    transform-origin: 12% 6%; /* attach point at the rump */
    animation: cow-tail-sway 14s ease-in-out infinite;
}

.cow-ear {
    transform-box: fill-box;
    transform-origin: 10% 65%;
    animation: cow-ear-twitch 14s ease-in-out infinite;
}

.cow-eye {
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: cow-blink 14s linear infinite;
}

.cow-muzzleg {
    transform-box: fill-box;
    transform-origin: 50% 45%;
    animation: cow-chew 14s ease-in-out infinite;
}

/* Coat colors come from per-cow CSS variables set inline by script.js
   (three pastel variants); fallbacks are the classic holstein palette. */
.cow-shadow { fill: rgba(40, 60, 40, 0.18); }
.cow-body, .cow-face {
    fill: var(--cow-coat, #fbfaf6);
    stroke: var(--cow-outline, #d8d2c4);
    stroke-width: 0.8;
}
.cow-spot { fill: var(--cow-spot, #3a3128); }
.cow-head-patch { fill: var(--cow-spot, #3a3128); opacity: 0.9; }
.cow-forelock { fill: var(--cow-spot, #3a3128); }
.cow-leg-upper {
    fill: var(--cow-coat, #fbfaf6);
    stroke: var(--cow-outline, #d8d2c4);
    stroke-width: 0.6;
}
.cow-leg-far .cow-leg-upper { fill: var(--cow-coat-dark, #e7e1d4); stroke: none; }
.cow-hoof { fill: var(--cow-hoof, #3a3128); }
.cow-leg-far .cow-hoof { opacity: 0.7; }
.cow-tail-line {
    fill: none;
    stroke: var(--cow-coat-dark, #e7e1d4);
    stroke-width: 2.4;
    stroke-linecap: round;
}
.cow-tail-tuft { fill: var(--cow-spot, #3a3128); }
.cow-udder { fill: #f0c6c0; }
.cow-muzzle { fill: var(--cow-muzzle, #efcdb4); }
.cow-nostril { fill: var(--cow-nose, #6b4a38); }
.cow-mouth {
    fill: none;
    stroke: var(--cow-nose, #6b4a38);
    stroke-width: 0.9;
    stroke-linecap: round;
    opacity: 0.55;
}
.cow-pupil { fill: #241d18; }
.cow-eye-glint { fill: #ffffff; opacity: 0.9; }
.cow-ear-outer {
    fill: var(--cow-coat, #fbfaf6);
    stroke: var(--cow-outline, #d8d2c4);
    stroke-width: 0.6;
}
.cow-ear-inner { fill: var(--cow-ear, #e9b9a2); }
.cow-horn { fill: none; stroke: #d8cdb8; stroke-width: 2.2; stroke-linecap: round; }

/* Walk right, pause + graze, turn, walk left, pause + graze, turn — loops seamlessly
   since 100% matches 0% exactly. */
@keyframes cow-walk {
    0%   { transform: translateX(0)    scaleX(-1); }
    28%  { transform: translateX(80px) scaleX(-1); }
    46%  { transform: translateX(80px) scaleX(-1); }
    50%  { transform: translateX(80px) scaleX(1); }
    78%  { transform: translateX(0)    scaleX(1); }
    96%  { transform: translateX(0)    scaleX(1); }
    100% { transform: translateX(0)    scaleX(-1); }
}

/* Head dips down to graze during the two pauses in cow-walk above (GRAZE_FRACTIONS
   in script.js targets the middle of these windows for the grass-bit bursts;
   cow-chew in script.js oscillates inside the 32–42 / 82–92 head-down holds). */
@keyframes cow-head-bob {
    0%, 26%   { transform: translate(0, 0) rotate(0deg); }
    32%, 42%  { transform: translate(1px, 7px) rotate(10deg); }
    48%, 76%  { transform: translate(0, 0) rotate(0deg); }
    82%, 92%  { transform: translate(1px, 7px) rotate(10deg); }
    98%, 100% { transform: translate(0, 0) rotate(0deg); }
}

/* Lazy sway while walking, one brisk fly-swat flick mid-graze. */
@keyframes cow-tail-sway {
    0%          { transform: rotate(0deg); }
    7%          { transform: rotate(8deg); }
    14%         { transform: rotate(-5deg); }
    21%         { transform: rotate(7deg); }
    28%, 33%    { transform: rotate(0deg); }
    35.5%       { transform: rotate(-30deg); }
    38%         { transform: rotate(12deg); }
    40%, 50%    { transform: rotate(0deg); }
    57%         { transform: rotate(8deg); }
    64%         { transform: rotate(-5deg); }
    71%         { transform: rotate(7deg); }
    78%, 84%    { transform: rotate(0deg); }
    86.5%       { transform: rotate(-30deg); }
    89%         { transform: rotate(12deg); }
    91%, 100%   { transform: rotate(0deg); }
}

/* Quick double ear flicks — once during each graze, one mid-walk. */
@keyframes cow-ear-twitch {
    0%, 33%, 36%, 57%, 59.5%, 83%, 86%, 100% { transform: rotate(0deg); }
    34%, 84.5% { transform: rotate(16deg); }
    35%        { transform: rotate(-6deg); }
    58.2%      { transform: rotate(12deg); }
}

/* A few ~140ms blinks scattered through the cycle. */
@keyframes cow-blink {
    0%, 9.4%, 10.4%, 36%, 37%, 61.4%, 62.4%, 88%, 89%, 100% { transform: scaleY(1); }
    9.9%, 36.5%, 61.9%, 88.5% { transform: scaleY(0.12); }
}

@keyframes cow-pat-wiggle {
    0%   { transform: scale(1, 1) rotate(0deg); }
    20%  { transform: scale(1.05, 0.92) rotate(-4deg); }
    45%  { transform: scale(0.96, 1.05) rotate(3deg); }
    70%  { transform: scale(1.03, 0.97) rotate(-2deg); }
    100% { transform: scale(1, 1) rotate(0deg); }
}

.grass-bit {
    position: fixed;
    z-index: 60;
    width: 3px;
    height: 6px;
    margin: -3px 0 0 -1px;
    background: linear-gradient(#63ad64, #457f4b);
    border-radius: 1px;
    pointer-events: none;
    animation: grass-bit-fall 650ms ease-in forwards;
    will-change: transform, opacity;
}

@keyframes grass-bit-fall {
    0%   { opacity: 1; transform: translate(0, 0) rotate(0deg); }
    100% { opacity: 0; transform: translate(var(--dx, 0px), 20px) rotate(var(--rot, 0deg)); }
}

.pat-sparkle {
    position: fixed;
    z-index: 61;
    font-size: 14px;
    line-height: 1;
    pointer-events: none;
    animation: pat-sparkle-pop 700ms ease-out forwards;
    will-change: transform, opacity;
}

@keyframes pat-sparkle-pop {
    0%   { opacity: 0; transform: translate(0, 0) scale(0.4) rotate(0deg); }
    25%  { opacity: 1; transform: translate(0, -6px) scale(1.1) rotate(-8deg); }
    100% { opacity: 0; transform: translate(var(--dx, 0px), -34px) scale(0.9) rotate(12deg); }
}

/* Occasional speech bubble, spawned by JS above the cow — matches the site's
   glassy surfaces. */
.moo-bubble {
    position: fixed;
    z-index: 61;
    padding: 3px 9px 4px;
    font: 600 11px/1.2 Inter, system-ui, sans-serif;
    letter-spacing: 0.02em;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    border-bottom-left-radius: 2px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
    animation: moo-pop 1600ms ease-out forwards;
    will-change: transform, opacity;
}

@keyframes moo-pop {
    0%   { opacity: 0; transform: translate(-50%, -90%) scale(0.6); }
    12%  { opacity: 1; transform: translate(-50%, -120%) scale(1); }
    75%  { opacity: 1; transform: translate(-50%, -135%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -160%) scale(0.97); }
}

@media (max-width: 640px) {
    .cow-pen { height: 56px; }
    .cow-gallery { grid-template-columns: 1fr; }
}
