|
| 1 | +/* Dark Mode Styles for Learn You a Haskell */ |
| 2 | + |
| 3 | +/* Dark mode is activated by adding 'dark-mode' class to body */ |
| 4 | +body.dark-mode { |
| 5 | + background-color: #1a1a1a; |
| 6 | + color: #e0e0e0; |
| 7 | +} |
| 8 | + |
| 9 | +body.dark-mode.introcontent { |
| 10 | + /* Add a semi-transparent dark overlay on top of bg.png */ |
| 11 | + background-image: linear-gradient(rgba(26, 26, 26, 0.75), rgba(26, 26, 26, 0.75)), url(../images/bg.png); |
| 12 | + background-color: #1a1a1a; |
| 13 | +} |
| 14 | + |
| 15 | +body.dark-mode .bgwrapper { |
| 16 | + background-color: #1a1a1a; |
| 17 | +} |
| 18 | + |
| 19 | +body.dark-mode h1, |
| 20 | +body.dark-mode h2, |
| 21 | +body.dark-mode h3 { |
| 22 | + color: #e0e0e0; |
| 23 | +} |
| 24 | + |
| 25 | +body.dark-mode a { |
| 26 | + color: #66b3ff; |
| 27 | +} |
| 28 | + |
| 29 | +body.dark-mode a:visited { |
| 30 | + color: #9999ff; |
| 31 | +} |
| 32 | + |
| 33 | +body.dark-mode a:hover { |
| 34 | + color: #ff6666; |
| 35 | +} |
| 36 | + |
| 37 | +body.dark-mode :not(pre) > code:not(.label, .function, .type, .class, .law) { |
| 38 | + background-color: #2d2d2d; |
| 39 | + color: #e0e0e0; |
| 40 | +} |
| 41 | + |
| 42 | +body.dark-mode pre > code { |
| 43 | + background-color: #0d0d0d; |
| 44 | + color: #90ee90; |
| 45 | +} |
| 46 | + |
| 47 | +body.dark-mode .hintbox { |
| 48 | + background-color: #2d2d1a; |
| 49 | + background-image: none !important; |
| 50 | + color: #f0f0f0; |
| 51 | + border: 1px solid #5a5a3a; |
| 52 | +} |
| 53 | + |
| 54 | +body.dark-mode .chapters > li > a { |
| 55 | + color: #e0e0e0; |
| 56 | + border-bottom: 1px solid #404040; |
| 57 | +} |
| 58 | + |
| 59 | +body.dark-mode .chapters > li > a:visited { |
| 60 | + color: #b0b0b0; |
| 61 | +} |
| 62 | + |
| 63 | +body.dark-mode .chapters > li > a:hover { |
| 64 | + color: #ff6666; |
| 65 | +} |
| 66 | + |
| 67 | +body.dark-mode .chapters > li > ul > li > a { |
| 68 | + color: #e0e0e0; |
| 69 | +} |
| 70 | + |
| 71 | +body.dark-mode .chapters > li > ul > li > a:visited { |
| 72 | + color: #b0b0b0; |
| 73 | +} |
| 74 | + |
| 75 | +body.dark-mode .chapters > li > ul > li > a:hover { |
| 76 | + color: #ff6666; |
| 77 | +} |
| 78 | + |
| 79 | +body.dark-mode .errata { |
| 80 | + background-color: #3d1a1a; |
| 81 | + color: #e0e0e0; |
| 82 | +} |
| 83 | + |
| 84 | +/* Dark mode toggle button */ |
| 85 | +.dark-mode-toggle { |
| 86 | + position: fixed; |
| 87 | + top: 40px; |
| 88 | + right: 20px; |
| 89 | + /* Using z-index 10000 to match the Ukraine banner and ensure visibility */ |
| 90 | + z-index: 10000; |
| 91 | + background-color: #333; |
| 92 | + color: white; |
| 93 | + border: 2px solid #555; |
| 94 | + border-radius: 50%; |
| 95 | + width: 50px; |
| 96 | + height: 50px; |
| 97 | + cursor: pointer; |
| 98 | + font-size: 24px; |
| 99 | + display: flex; |
| 100 | + align-items: center; |
| 101 | + justify-content: center; |
| 102 | + transition: all 0.3s ease; |
| 103 | + box-shadow: 0 2px 5px rgba(0,0,0,0.3); |
| 104 | +} |
| 105 | + |
| 106 | +.dark-mode-toggle:hover { |
| 107 | + background-color: #444; |
| 108 | + transform: scale(1.1); |
| 109 | +} |
| 110 | + |
| 111 | +body.dark-mode .dark-mode-toggle { |
| 112 | + background-color: #f0f0f0; |
| 113 | + color: #333; |
| 114 | + border-color: #ccc; |
| 115 | +} |
| 116 | + |
| 117 | +body.dark-mode .dark-mode-toggle:hover { |
| 118 | + background-color: #e0e0e0; |
| 119 | +} |
| 120 | + |
| 121 | +/* Adjust toggle button for mobile */ |
| 122 | +@media screen and (max-width: 600px) { |
| 123 | + .dark-mode-toggle { |
| 124 | + width: 45px; |
| 125 | + height: 45px; |
| 126 | + font-size: 20px; |
| 127 | + top: 40px; |
| 128 | + right: 10px; |
| 129 | + } |
| 130 | +} |
| 131 | + |
| 132 | +/* Dark mode for index page specific elements */ |
| 133 | +body.dark-mode { |
| 134 | + background-color: #1a1a1a !important; |
| 135 | +} |
| 136 | + |
| 137 | +body.dark-mode #newsplash { |
| 138 | + color: #e0e0e0; |
| 139 | + background-color: #1a1a1a !important; |
| 140 | + position: relative; |
| 141 | + overflow: hidden; /* Prevent content from spilling outside the container */ |
| 142 | +} |
| 143 | + |
| 144 | +/* Add a dark overlay using pseudo-element to dim background while keeping text readable */ |
| 145 | +body.dark-mode #newsplash::before { |
| 146 | + content: ""; |
| 147 | + position: absolute; |
| 148 | + top: 0; |
| 149 | + left: 0; |
| 150 | + right: 0; |
| 151 | + bottom: 0; |
| 152 | + background-color: rgba(26, 26, 26, 0.40); |
| 153 | + pointer-events: none; |
| 154 | + z-index: 0; |
| 155 | +} |
| 156 | + |
| 157 | +/* Ensure content is above the overlay and constrain width to prevent overflow */ |
| 158 | +/* The text div is absolutely positioned, so we need to constrain it with explicit left/right */ |
| 159 | +/* Parent container is 880px wide, text should wrap within it with proper margins */ |
| 160 | +body.dark-mode #newsplash > div[style*="position:absolute"] { |
| 161 | + position: absolute !important; /* Keep original positioning */ |
| 162 | + z-index: 1; |
| 163 | + left: 0 !important; |
| 164 | + right: 20px !important; /* 20px margin on the right to prevent overflow */ |
| 165 | + padding-left: 20px; /* Match the left padding to keep text centered */ |
| 166 | + padding-right: 20px; /* Additional padding for safety */ |
| 167 | + box-sizing: border-box; |
| 168 | +} |
| 169 | + |
| 170 | +body.dark-mode .newsplash a.nostarchlink { |
| 171 | + color: #66b3ff; |
| 172 | +} |
| 173 | + |
| 174 | +body.dark-mode .newsplash a.nostarchlink:hover { |
| 175 | + color: #ff6666; |
| 176 | +} |
| 177 | + |
| 178 | +/* Make index page buttons slightly more visible in dark mode without hiding graphics */ |
| 179 | +body.dark-mode #faq-button, |
| 180 | +body.dark-mode #book-button, |
| 181 | +body.dark-mode #read-button { |
| 182 | + /* Keep the buttons as clickable areas over the dimmed graphics */ |
| 183 | + opacity: 1; |
| 184 | +} |
| 185 | + |
| 186 | +/* Handle image backgrounds in dark mode */ |
| 187 | +body.dark-mode img { |
| 188 | + opacity: 0.9; |
| 189 | + background-color: transparent; |
| 190 | +} |
| 191 | + |
| 192 | +/* Keep images at full opacity when needed */ |
| 193 | +body.dark-mode img.full-opacity { |
| 194 | + opacity: 1; |
| 195 | +} |
0 commit comments