/* ===== Material Design 3 (M3) CSS Variables ===== */
:root {
    /* M3 Primary Tonal Palette */
    --md-sys-color-primary: #ff9494;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #ffe5e5;
    --md-sys-color-on-primary-container: #5c1f1f;
    
    /* M3 Secondary */
    --md-sys-color-secondary: #d67070;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #ffe5e5;
    --md-sys-color-on-secondary-container: #051F1F;
    
    /* M3 Tertiary */
    --md-sys-color-tertiary: #4B607C;
    --md-sys-color-on-tertiary: #FFFFFF;
    --md-sys-color-tertiary-container: #D3E4FF;
    --md-sys-color-on-tertiary-container: #041C35;
    
    /* M3 Error */
    --md-sys-color-error: #BA1A1A;
    --md-sys-color-on-error: #FFFFFF;
    --md-sys-color-error-container: #FFDAD6;
    --md-sys-color-on-error-container: #410002;
    
    /* M3 Surface */
    --md-sys-color-surface: #FAFDFC;
    --md-sys-color-on-surface: #191C1C;
    --md-sys-color-surface-variant: #DAE5E4;
    --md-sys-color-on-surface-variant: #3F4948;
    --md-sys-color-surface-container-lowest: #FFFFFF;
    --md-sys-color-surface-container-low: #F4F7F6;
    --md-sys-color-surface-container: #EEF1F0;
    --md-sys-color-surface-container-high: #E8EBEA;
    --md-sys-color-surface-container-highest: #E3E6E5;
    
    /* M3 Outline */
    --md-sys-color-outline: #6F7979;
    --md-sys-color-outline-variant: #BEC9C8;
    
    /* M3 Background */
    --md-sys-color-background: #FAFDFC;
    --md-sys-color-on-background: #191C1C;
    
    /* M3 Typography */
    --md-sys-typescale-display-large: 400 57px/64px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-display-medium: 400 45px/52px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-display-small: 400 36px/44px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-headline-large: 400 32px/40px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-headline-medium: 400 28px/36px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-headline-small: 400 24px/32px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-title-large: 400 22px/28px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-title-medium: 500 16px/24px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-title-small: 500 14px/20px 'Google Sans', 'Roboto', sans-serif;
    --md-sys-typescale-body-large: 400 16px/24px 'Roboto', sans-serif;
    --md-sys-typescale-body-medium: 400 14px/20px 'Roboto', sans-serif;
    --md-sys-typescale-body-small: 400 12px/16px 'Roboto', sans-serif;
    --md-sys-typescale-label-large: 500 14px/20px 'Roboto', sans-serif;
    --md-sys-typescale-label-medium: 500 12px/16px 'Roboto', sans-serif;
    --md-sys-typescale-label-small: 500 11px/16px 'Roboto', sans-serif;
    
    /* M3 Shape */
    --md-sys-shape-corner-none: 0px;
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small: 8px;
    --md-sys-shape-corner-medium: 12px;
    --md-sys-shape-corner-large: 16px;
    --md-sys-shape-corner-extra-large: 28px;
    --md-sys-shape-corner-full: 9999px;
    
    /* M3 Elevation */
    --md-sys-elevation-1: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-2: 0px 1px 2px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-sys-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px rgba(0, 0, 0, 0.3);
    
    /* Layout */
    --max-width: 1200px;
    --top-nav-height: 64px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font: var(--md-sys-typescale-body-large);
    background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--md-sys-color-primary);
    text-decoration: none;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
}

a:hover {
    color: var(--md-sys-color-on-primary-container);
}

/* ===== App Layout ===== */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Navigation Bar ===== */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-nav-height);
    background-color: var(--md-sys-color-surface);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
    box-shadow: var(--md-sys-elevation-1);
}

.nav-bar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 16px;
    flex-shrink: 0;
}

.nav-bar-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--md-sys-shape-corner-medium);
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    overflow: hidden;
}

.nav-bar-logo:hover {
    background-color: #cc6666;
    transform: scale(1.05);
}

.nav-bar-logo:hover .nav-logo-img {
    filter: brightness(0) invert(1);
}

.nav-logo-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.nav-bar-title-group {
  display: flex;
  flex-direction: column;
}

.nav-bar-title {
  font-family: 'Calistoga', serif;
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.5rem;
  color: var(--md-sys-color-on-surface);
  display: block;
  white-space: nowrap;
}

.nav-bar-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1rem;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
}

.nav-bar-items {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    margin-right: 0;
}

.nav-bar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--md-sys-shape-corner-full);
    cursor: pointer;
    text-decoration: none;
    color: var(--md-sys-color-on-surface-variant);
    font: var(--md-sys-typescale-label-large);
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    position: relative;
    overflow: hidden;
}

.nav-bar-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: currentColor;
    opacity: 0;
    transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1);
}

.nav-bar-item:hover {
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
}

.nav-bar-item:hover::before {
    opacity: 0.08;
}

.nav-bar-item.active {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.nav-bar-item.active:hover::before {
    opacity: 0;
}

.nav-bar-item .material-icons {
    font-size: 20px;
}

.nav-bar-item-label {
    white-space: nowrap;
}

/* ===== Main Content ===== */
.main-content {
    margin-top: var(--top-nav-height);
    flex: 1;
    min-height: calc(100vh - var(--top-nav-height));
}

.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ===== Loading & Error States ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 16px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--md-sys-color-surface-container);
    border-top-color: var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface-variant);
}

/* ===== Recipe List Page ===== */
.recipe-list-container {
    max-width: 1200px;
    margin: 0 auto;
}

.recipe-list-header {
    margin-bottom: 32px;
    text-align: center;
}

.recipe-list-title {
    font: var(--md-sys-typescale-headline-large);
    font-family: 'Calistoga', serif;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
}

.recipe-list-subtitle {
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface-variant);
}

.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.recipe-search-container {
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
}

.recipe-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    max-width: 600px;
    width: 100%;
}

.recipe-search-icon {
    position: absolute;
    left: 16px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 24px;
    pointer-events: none;
}

.recipe-search-input {
    width: 100%;
    height: 56px;
    padding: 0 16px 0 56px;
    border-radius: var(--md-sys-shape-corner-full);
    border: 1px solid var(--md-sys-color-outline-variant);
    background-color: var(--md-sys-color-surface-container-low);
    color: var(--md-sys-color-on-surface);
    font: var(--md-sys-typescale-body-large);
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
}

.recipe-search-input:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface);
    box-shadow: 0 0 0 2px rgba(255, 148, 148, 0.2);
}

.recipe-search-input::placeholder {
    color: var(--md-sys-color-on-surface-variant);
}

.recipe-results-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
}

.recipe-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
}

.recipe-no-results .material-icons {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.recipe-no-results p {
    font: var(--md-sys-typescale-body-large);
}

/* ===== All Recipes Page ===== */
.all-recipes-container {
    max-width: 1200px;
    margin: 0 auto;
}

.all-recipes-header {
    margin-bottom: 32px;
    text-align: center;
}

.all-recipes-title {
    font: var(--md-sys-typescale-headline-large);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
}

.all-recipes-count {
    font: var(--md-sys-typescale-body-large);
    color: var(--md-sys-color-on-surface-variant);
}

.all-recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

/* ===== Recipe Card ===== */
.recipe-card {
    display: flex;
    flex-direction: column;
    padding: 24px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-large);
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    text-decoration: none;
    color: inherit;
    position: relative;
    min-height: 180px;
    width: 100%;
}

.recipe-card:hover {
    box-shadow: var(--md-sys-elevation-2);
    transform: translateY(-2px);
}

.md-card {
    background-color: var(--md-sys-color-surface-container-low);
}

.md-card-elevated {
    box-shadow: var(--md-sys-elevation-1);
}

.recipe-card-header {
    flex: 1;
    margin-bottom: 16px;
}

.recipe-card-title {
    font: var(--md-sys-typescale-title-large);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 8px;
}

.recipe-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.recipe-card-tag {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--md-sys-shape-corner-full);
    font: var(--md-sys-typescale-label-small);
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.recipe-card-metadata {
    display: flex;
    gap: 16px;
    margin-top: auto;
}

.recipe-card-time {
    display: flex;
    align-items: center;
    gap: 4px;
    font: var(--md-sys-typescale-body-small);
    color: var(--md-sys-color-on-surface-variant);
}

.recipe-card-time .material-icons {
    font-size: 16px;
}

.recipe-card-arrow {
    position: absolute;
    top: 24px;
    right: 24px;
    font-size: 24px;
    color: var(--md-sys-color-on-surface-variant);
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
}

.recipe-card:hover .recipe-card-arrow {
    color: var(--md-sys-color-primary);
    transform: translateX(4px);
}

/* ===== Recipe Page Styles ===== */
.recipe-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
}

.recipe-back-button-container {
    margin-bottom: 24px;
    margin-top: 8px;
}

.recipe-back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--md-sys-shape-corner-full);
    color: var(--md-sys-color-primary);
    font: var(--md-sys-typescale-label-large);
    text-decoration: none;
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
    background-color: transparent;
    border: none;
    cursor: pointer;
}

.recipe-back-button:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    text-decoration: none;
}

.recipe-back-button .material-icons {
    font-size: 20px;
}

.recipe-header {
    margin-bottom: 32px;
}

.recipe-title {
    font-family: 'Calistoga', serif;
    font-weight: 400;
    font-size: 2.5rem;
    line-height: 3rem;
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
}

.recipe-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-bottom: 24px;
    padding: 16px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}

.recipe-metadata-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
}

.recipe-metadata-item .material-icons {
    font-size: 18px;
    color: var(--md-sys-color-primary);
}

.recipe-metadata-label {
    font-weight: 500;
    color: var(--md-sys-color-on-surface);
}

.recipe-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
}

.recipe-tag {
    display: inline-flex;
    align-items: center;
    height: 32px;
    padding: 0 16px;
    border-radius: var(--md-sys-shape-corner-full);
    font: var(--md-sys-typescale-label-large);
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    transition: all 200ms cubic-bezier(0.2, 0, 0, 1);
}

.recipe-tag:hover {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

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

.recipe-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font: var(--md-sys-typescale-title-medium);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--md-sys-color-primary-container);
}

.recipe-section-title .material-icons {
    font-size: 24px;
    color: var(--md-sys-color-primary);
}

.recipe-ingredients {
    padding: 20px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}

.recipe-ingredients-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recipe-ingredient-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface);
    line-height: 1.6;
}

.recipe-ingredient-checkbox {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--md-sys-color-primary);
}

.recipe-ingredient-checkbox:checked + label {
    text-decoration: line-through;
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.7;
}

.recipe-ingredient-item label {
    cursor: pointer;
    flex: 1;
    user-select: none;
}

.recipe-instructions {
    padding: 20px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}

.recipe-instructions-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: instruction-counter;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.recipe-instruction-item {
    counter-increment: instruction-counter;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface);
    line-height: 1.6;
    position: relative;
    padding-left: 48px;
}

.recipe-instruction-item::before {
    content: counter(instruction-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-radius: var(--md-sys-shape-corner-full);
    font: var(--md-sys-typescale-label-large);
    font-weight: 500;
    flex-shrink: 0;
}

.recipe-notes {
    padding: 20px;
    background-color: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-sys-shape-corner-medium);
}

.recipe-notes-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recipe-note-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.6;
    font-style: italic;
}

.recipe-note-item::before {
    content: 'note';
    font-family: 'Material Icons';
    font-size: 18px;
    color: var(--md-sys-color-tertiary);
    margin-top: 2px;
    flex-shrink: 0;
}

/* ===== Responsive Design ===== */
@media (min-width: 1248px) {
    .nav-bar {
        padding-left: calc((100% - var(--max-width)) / 2);
        padding-right: calc((100% - var(--max-width)) / 2);
    }
}

@media (max-width: 768px) {
    .page-container {
        padding: 24px 16px;
    }
    
    .recipe-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .recipe-title {
        font-size: 2rem;
        line-height: 2.5rem;
    }
    
    .recipe-metadata {
        flex-direction: column;
        gap: 12px;
    }
    
    .recipe-ingredients,
    .recipe-instructions,
    .recipe-notes {
        padding: 16px;
    }
    
    .recipe-instruction-item {
        padding-left: 40px;
    }
    
    .recipe-instruction-item::before {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .recipe-title {
        font-size: 1.75rem;
        line-height: 2.25rem;
    }
    
    .nav-bar {
        padding: 0 16px;
    }
    
    .nav-bar-title {
        display: none;
    }
    
    .recipe-search-wrapper {
        max-width: 100%;
    }
    
    .recipe-search-input {
        height: 48px;
        font-size: 16px;
    }
}
