import re
import os

css_path = 'chef-kamil/css/style.css'
with open(css_path, 'r', encoding='utf-8') as f:
    css_content = f.read()

# Add the hero and story styles to style.css if not already there
new_css = """
/* Hero & Story Elements */
.hero-story {
  background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.7)), url('../images/dismekan.jpg') center/cover no-repeat;
  height: 40vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-main);
  padding-top: 5rem;
}
.hero-story h1 {
  font-size: 3rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}
.hero-story p {
  font-size: 1.2rem;
  max-width: 800px;
  margin: 0 auto;
}
.story-section {
  padding: 4rem 5%;
  background: var(--bg-color);
  color: var(--text-main);
}
.story-content {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}
.story-content h2 {
  color: var(--gold);
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
}
.story-content p {
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
  color: #ccc;
}
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}
.rule-card {
  background: var(--card-bg);
  padding: 2.5rem 1.5rem;
  border-radius: 8px;
  border-bottom: 3px solid var(--gold);
  transition: transform 0.3s;
}
.rule-card:hover {
  transform: translateY(-10px);
}
.rule-card h3 {
  color: var(--gold);
  font-size: 1.8rem;
  margin-bottom: 1rem;
}
"""

if ".hero-story" not in css_content:
    with open(css_path, 'a', encoding='utf-8') as f:
        f.write(new_css)

# Remove <style>...</style> from index.html and hakkimizda.html
for filepath in ['chef-kamil/index.html', 'chef-kamil/hakkimizda.html']:
    with open(filepath, 'r', encoding='utf-8') as f:
        html = f.read()
    
    html = re.sub(r'<style>.*?</style>', '', html, flags=re.DOTALL)
    
    with open(filepath, 'w', encoding='utf-8') as f:
        f.write(html)

# Update menu.html and blog/index.html
for filepath in ['chef-kamil/menu.html', 'chef-kamil/blog/index.html']:
    with open(filepath, 'r', encoding='utf-8') as f:
        html = f.read()
    
    html = re.sub(r'<section class="hero" style="height: [^"]+;">', '<section class="hero-story">', html)
    html = re.sub(r'<div class="hero-content">', '<div class="hero-content fade-in">', html)
    
    # Wait, blog/index.html has <link rel="stylesheet" href="../css/style.css">
    # The URL url('../images/dismekan.jpg') in style.css works from css/ to images/. So it is correct.
    
    with open(filepath, 'w', encoding='utf-8') as f:
        f.write(html)

print("Styles moved to style.css and hero banners fixed.")
