frontblocks-cookie-notice.css
283 lines
| 1 | /** |
| 2 | * FrontBlocks Cookie Notice Styles |
| 3 | * |
| 4 | * @package FrontBlocks |
| 5 | * @version 1.0.0 |
| 6 | */ |
| 7 | |
| 8 | .frbl-cookie-notice { |
| 9 | --frbl-cookie-accent: #687df9; |
| 10 | --frbl-cookie-accent-contrast: #ffffff; |
| 11 | --frbl-cookie-accent-on-light: #687df9; |
| 12 | --frbl-cookie-bg: #ffffff; |
| 13 | --frbl-cookie-text: #1f2937; |
| 14 | --frbl-cookie-radius: 12px; |
| 15 | |
| 16 | position: fixed; |
| 17 | z-index: 999999; |
| 18 | box-sizing: border-box; |
| 19 | font-family: inherit; |
| 20 | line-height: 1.5; |
| 21 | opacity: 1; |
| 22 | transition: opacity 0.3s ease, transform 0.3s ease; |
| 23 | } |
| 24 | |
| 25 | .frbl-cookie-notice * { |
| 26 | box-sizing: border-box; |
| 27 | } |
| 28 | |
| 29 | .frbl-cookie-notice--hidden { |
| 30 | opacity: 0; |
| 31 | pointer-events: none; |
| 32 | } |
| 33 | |
| 34 | /* |
| 35 | * Initial, pre-decision state: printed by the server this way so a visitor |
| 36 | * who already accepted/rejected never sees the banner flash into view before |
| 37 | * frontblocks-cookie-notice.js hides it — the invisible state is the default, |
| 38 | * not something applied after the fact. It doubles as the "from" state of the |
| 39 | * entrance animation for a visitor who still needs to decide: the script |
| 40 | * removes this class once it determines that, letting the transition above |
| 41 | * animate it in. A `<noscript>` rule further down resets it to visible for |
| 42 | * browsers that never run the script at all. |
| 43 | */ |
| 44 | .frbl-cookie-notice--init { |
| 45 | opacity: 0; |
| 46 | pointer-events: none; |
| 47 | } |
| 48 | |
| 49 | .frbl-cookie-notice--bar.frbl-cookie-notice--init { |
| 50 | transform: translateY(100%); |
| 51 | } |
| 52 | |
| 53 | .frbl-cookie-notice--box.frbl-cookie-notice--init { |
| 54 | transform: translateX(100%); |
| 55 | } |
| 56 | |
| 57 | .frbl-cookie-notice--box.frbl-cookie-notice--left.frbl-cookie-notice--init { |
| 58 | transform: translateX(-100%); |
| 59 | } |
| 60 | |
| 61 | .frbl-cookie-notice--popup.frbl-cookie-notice--init { |
| 62 | transform: scale(0.96); |
| 63 | } |
| 64 | |
| 65 | .frbl-cookie-notice__panel { |
| 66 | background-color: var(--frbl-cookie-bg); |
| 67 | color: var(--frbl-cookie-text); |
| 68 | border-radius: var(--frbl-cookie-radius); |
| 69 | overflow: hidden; |
| 70 | box-shadow: none; |
| 71 | } |
| 72 | |
| 73 | .frbl-cookie-notice__message { |
| 74 | margin: 0; |
| 75 | font-size: 14px; |
| 76 | color: var(--frbl-cookie-text); |
| 77 | } |
| 78 | |
| 79 | .frbl-cookie-notice__link { |
| 80 | color: var(--frbl-cookie-accent-on-light); |
| 81 | text-decoration: underline; |
| 82 | white-space: nowrap; |
| 83 | } |
| 84 | |
| 85 | .frbl-cookie-notice__actions { |
| 86 | display: flex; |
| 87 | flex-wrap: wrap; |
| 88 | gap: 12px; |
| 89 | flex-shrink: 0; |
| 90 | } |
| 91 | |
| 92 | .frbl-cookie-notice__button { |
| 93 | appearance: none; |
| 94 | border-radius: 6px; |
| 95 | padding: 10px 20px; |
| 96 | font-size: 14px; |
| 97 | font-weight: 600; |
| 98 | line-height: 1.2; |
| 99 | cursor: pointer; |
| 100 | transition: filter 0.15s ease, transform 0.15s ease; |
| 101 | white-space: nowrap; |
| 102 | } |
| 103 | |
| 104 | .frbl-cookie-notice__button:hover { |
| 105 | filter: brightness(0.92); |
| 106 | } |
| 107 | |
| 108 | .frbl-cookie-notice__button:active { |
| 109 | transform: scale(0.97); |
| 110 | } |
| 111 | |
| 112 | .frbl-cookie-notice__button:focus-visible { |
| 113 | outline: 2px solid var(--frbl-cookie-accent-on-light); |
| 114 | outline-offset: 2px; |
| 115 | } |
| 116 | |
| 117 | .frbl-cookie-notice__button--accept { |
| 118 | background-color: var(--frbl-cookie-accent); |
| 119 | border: 1px solid var(--frbl-cookie-accent); |
| 120 | color: var(--frbl-cookie-accent-contrast); |
| 121 | } |
| 122 | |
| 123 | .frbl-cookie-notice__button--reject { |
| 124 | background-color: transparent; |
| 125 | border: 1px solid #9ca3af; |
| 126 | color: var(--frbl-cookie-text); |
| 127 | } |
| 128 | |
| 129 | /* Bar layout: floating bottom bar, spanning most of the viewport width. */ |
| 130 | .frbl-cookie-notice--bar { |
| 131 | left: 20px; |
| 132 | right: 20px; |
| 133 | bottom: 20px; |
| 134 | max-height: calc(100vh - 40px); |
| 135 | overflow-y: auto; |
| 136 | } |
| 137 | |
| 138 | /* GeneratePress sets the content width in PHP, so match its centered page |
| 139 | container when FrontBlocks receives that value from the active theme. */ |
| 140 | .frbl-cookie-notice--bar.frbl-cookie-notice--generatepress { |
| 141 | left: max(20px, calc((100vw - var(--frbl-cookie-content-width)) / 2)); |
| 142 | right: max(20px, calc((100vw - var(--frbl-cookie-content-width)) / 2)); |
| 143 | } |
| 144 | |
| 145 | .frbl-cookie-notice--bar .frbl-cookie-notice__panel { |
| 146 | display: flex; |
| 147 | align-items: center; |
| 148 | justify-content: space-between; |
| 149 | gap: 16px; |
| 150 | flex-wrap: wrap; |
| 151 | padding: 16px 24px; |
| 152 | } |
| 153 | |
| 154 | .frbl-cookie-notice--bar .frbl-cookie-notice__message { |
| 155 | flex: 1 1 320px; |
| 156 | } |
| 157 | |
| 158 | /* Box layout: boxed panel anchored bottom-left or bottom-right. */ |
| 159 | .frbl-cookie-notice--box { |
| 160 | bottom: 20px; |
| 161 | max-width: 380px; |
| 162 | width: calc(100% - 40px); |
| 163 | max-height: calc(100vh - 40px); |
| 164 | overflow-y: auto; |
| 165 | } |
| 166 | |
| 167 | .frbl-cookie-notice--box.frbl-cookie-notice--right { |
| 168 | right: 20px; |
| 169 | } |
| 170 | |
| 171 | .frbl-cookie-notice--box.frbl-cookie-notice--left { |
| 172 | left: 20px; |
| 173 | } |
| 174 | |
| 175 | .frbl-cookie-notice--box .frbl-cookie-notice__panel { |
| 176 | padding: 20px; |
| 177 | display: flex; |
| 178 | flex-direction: column; |
| 179 | gap: 16px; |
| 180 | } |
| 181 | |
| 182 | .frbl-cookie-notice--box .frbl-cookie-notice__actions { |
| 183 | flex-direction: column; |
| 184 | } |
| 185 | |
| 186 | .frbl-cookie-notice--box .frbl-cookie-notice__button { |
| 187 | width: 100%; |
| 188 | text-align: center; |
| 189 | } |
| 190 | |
| 191 | /* Popup layout: centered modal with a dimmed backdrop. */ |
| 192 | .frbl-cookie-notice--popup { |
| 193 | inset: 0; |
| 194 | display: flex; |
| 195 | align-items: center; |
| 196 | justify-content: center; |
| 197 | padding: 20px; |
| 198 | overflow-y: auto; |
| 199 | background-color: transparent; |
| 200 | } |
| 201 | |
| 202 | .frbl-cookie-notice--popup .frbl-cookie-notice__panel { |
| 203 | padding: 40px 32px 32px; |
| 204 | max-width: 420px; |
| 205 | width: 100%; |
| 206 | max-height: calc(100vh - 40px); |
| 207 | overflow-y: auto; |
| 208 | display: flex; |
| 209 | flex-direction: column; |
| 210 | align-items: center; |
| 211 | text-align: center; |
| 212 | gap: 16px; |
| 213 | box-shadow: none; |
| 214 | } |
| 215 | |
| 216 | .frbl-cookie-notice__icon { |
| 217 | display: flex; |
| 218 | align-items: center; |
| 219 | justify-content: center; |
| 220 | width: 64px; |
| 221 | height: 64px; |
| 222 | flex-shrink: 0; |
| 223 | border-radius: 50%; |
| 224 | background-color: var(--frbl-cookie-accent); |
| 225 | color: var(--frbl-cookie-accent-contrast); |
| 226 | } |
| 227 | |
| 228 | .frbl-cookie-notice__icon svg { |
| 229 | width: 32px; |
| 230 | height: 32px; |
| 231 | } |
| 232 | |
| 233 | .frbl-cookie-notice--popup .frbl-cookie-notice__actions { |
| 234 | justify-content: center; |
| 235 | width: 100%; |
| 236 | } |
| 237 | |
| 238 | body.frbl-cookie-notice-lock-scroll { |
| 239 | overflow: hidden; |
| 240 | } |
| 241 | |
| 242 | @media (max-width: 600px) { |
| 243 | .frbl-cookie-notice--bar .frbl-cookie-notice__panel { |
| 244 | padding: 16px; |
| 245 | } |
| 246 | |
| 247 | .frbl-cookie-notice--bar .frbl-cookie-notice__actions, |
| 248 | .frbl-cookie-notice--popup .frbl-cookie-notice__actions { |
| 249 | flex-direction: column; |
| 250 | width: 100%; |
| 251 | } |
| 252 | |
| 253 | .frbl-cookie-notice--bar .frbl-cookie-notice__button, |
| 254 | .frbl-cookie-notice--popup .frbl-cookie-notice__button { |
| 255 | width: 100%; |
| 256 | text-align: center; |
| 257 | } |
| 258 | |
| 259 | .frbl-cookie-notice--box, |
| 260 | .frbl-cookie-notice--popup .frbl-cookie-notice__panel { |
| 261 | width: calc(100% - 24px); |
| 262 | max-width: none; |
| 263 | } |
| 264 | |
| 265 | .frbl-cookie-notice--popup .frbl-cookie-notice__panel { |
| 266 | max-height: calc(100vh - 24px); |
| 267 | } |
| 268 | |
| 269 | .frbl-cookie-notice--box, |
| 270 | .frbl-cookie-notice--bar { |
| 271 | left: 12px; |
| 272 | right: 12px; |
| 273 | bottom: 12px; |
| 274 | max-height: calc(100vh - 24px); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | @media (prefers-reduced-motion: reduce) { |
| 279 | .frbl-cookie-notice { |
| 280 | transition: none; |
| 281 | } |
| 282 | } |
| 283 |