/* ============================================================
   BASE RESET & BODY
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: 'Raleway', sans-serif;
    background-color: #121212;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
}

img, video, iframe, canvas {
    max-width: 100%;
    height: auto;
}

p, li, span, div {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* ============================================================
   CONTAINERS
   ============================================================ */
.header-container,
.chapter,
.content,
.footer,
header {
    width: 100%;
    max-width: 100%;
}

.header-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 15px;
}

.header-container h1 {
    margin: 0;
    font-size: 2em;
    font-family: 'Playfair Display', serif;
    color: #ffeb3b;
    word-wrap: break-word;
}

.header-container p {
    font-size: 1em;
    margin-top: 10px;
    color: #e0e0e0;
    word-wrap: break-word;
}

/* ============================================================
   CHAPTER LAYOUT
   ============================================================ */
.chapter {
    margin: 0 auto;
    padding: 20px;
    max-width: 1000px;
    background-color: #1a1a1a;
    border: 1px solid #444444;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    width: 100%;
}

.chapter-intro {
    text-align: justify;
    margin-bottom: 20px;
    color: #e0e0e0;
    padding: 0 15px;
    word-wrap: break-word;
}

.content {
    margin-bottom: 40px;
    text-align: justify;
    color: #e0e0e0;
    padding: 0 15px;
    word-wrap: break-word;
}

/* ============================================================
   IMAGES
   ============================================================ */
.chapter-drink-image {
    display: block;
    margin: 0 auto 10px auto;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 8px rgba(255, 235, 59, 0.3);
    max-width: 100%;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h2, h3 {
    color: #ffeb3b;
    margin-top: 20px;
    font-size: 1.4em;
    word-wrap: break-word;
}

/* ============================================================
   CODE BLOCKS
   ============================================================ */
pre {
    background-color: #2e2e2e;
    color: #ffeb3b;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    margin: 10px 0;
    max-width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
}

code {
    font-family: 'Courier New', monospace;
    background-color: #2e2e2e;
    color: #ffeb3b;
    padding: 2px 4px;
    border-radius: 3px;
    word-wrap: break-word;
    white-space: normal;
}

pre code {
    padding: 0;
    background: transparent;
}

/* ============================================================
   FOOTER & HEADER
   ============================================================ */
.footer,
header {
    background-color: #1f1f1f;
    color: #e0e0e0;
    padding: 10px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* ============================================================
   SOCIAL MEDIA
   ============================================================ */
.social-media {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.social-icon {
    color: #ffeb3b;
    font-size: 20px;
    margin: 0 10px;
    transition: transform 0.3s, color 0.3s;
    text-decoration: none;
}

.social-icon:hover {
    transform: scale(1.2);
    color: #ffd700;
}

/* ============================================================
   BACK-TO-TOP BUTTON
   ============================================================ */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 22px;
    background: #ffeb3b;
    color: #121212;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    font-family: 'Orbitron', 'Segoe UI', sans-serif;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 1px;
    box-shadow:
        0 0 10px rgba(255, 235, 59, 0.6),
        0 0 18px rgba(255, 235, 59, 0.4);
    pointer-events: none;
}

#backToTop.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

#backToTop:hover {
    background: #ffd700;
    box-shadow:
        0 0 12px rgba(255, 215, 0, 0.7),
        0 0 22px rgba(255, 235, 59, 0.6);
    transform: scale(1.08);
}

#backToTop:active {
    background: #b38f00;
    color: #ffffff;
    transform: scale(0.92);
}

/* ============================================================
   TABLES
   ============================================================ */
table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 0 auto;
    display: block;
    overflow-x: auto;
}

/* ============================================================
   RESPONSIVE — tablets & below (max 768px)
   ============================================================ */
@media (max-width: 768px) {
    .chapter {
        padding: 20px 15px;
        max-width: 100%;
        margin: 0 auto;
    }

    .header-container {
        text-align: center;
        align-items: center;
    }

    .header-container h1 {
        font-size: 1.5em;
    }

    .header-container p {
        font-size: 0.9em;
    }

    .chapter-intro,
    .content {
        text-align: left;
        padding: 0 5px;
    }

    .chapter-intro p,
    .content p {
        text-align: left;
    }

    h2, h3 {
        font-size: 1.2em;
        text-align: left;
    }

    .chapter-drink-image {
        width: 120px;
        height: 120px;
        margin: 0 auto 15px auto;
    }

    pre {
        font-size: 0.9em;
        text-align: left;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding: 10px;
    }

    code {
        font-size: 0.9em;
        text-align: left;
    }

    .social-icon {
        font-size: 18px;
        margin: 0 8px;
    }

    ul, ol {
        padding-left: 20px;
        list-style-position: outside;
        text-align: left;
        display: block;
        width: auto;
    }

    li {
        text-align: left;
        margin-bottom: 5px;
    }
}

/* ============================================================
   RESPONSIVE — small phones (max 480px)
   ============================================================ */
@media (max-width: 480px) {
    .chapter {
        padding: 15px 10px;
    }

    .header-container h1 {
        font-size: 1.3em;
    }

    .header-container p {
        font-size: 0.85em;
    }

    .chapter-intro,
    .content {
        font-size: 0.95em;
        padding: 0;
    }

    h2, h3 {
        font-size: 1.1em;
    }

    .chapter-drink-image {
        width: 100px;
        height: 100px;
        margin: 0 auto 10px auto;
    }

    .social-media {
        gap: 10px;
    }

    .social-icon {
        font-size: 16px;
        margin: 0 5px;
    }

    pre {
        font-size: 0.85em;
        padding: 8px;
    }

    #backToTop {
        bottom: 18px;
        right: 18px;
        padding: 12px 18px;
        font-size: 14px;
    }
}

/* ============================================================
   TOUCH DEVICES — larger tap target
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    #backToTop {
        padding: 16px 24px;
        font-size: 16px;
    }
}

/* ============================================================
   DESKTOP — left-aligned reading layout (min 769px)
   ============================================================ */
@media (min-width: 769px) {
    .chapter-intro,
    .content {
        text-align: justify;
    }

    .content p,
    .chapter-intro p {
        text-align: justify;
    }

    h2, h3 {
        text-align: left;
    }

    ul, ol {
        text-align: left;
        list-style-position: outside;
        padding-left: 20px;
    }

    li {
        text-align: left;
    }
}