]> git.cworth.org Git - lmno.games/blob - style.css
Parameterize the styling of the page width
[lmno.games] / style.css
1 /*\
2 |*|
3 |*| Properties for the page: colors, etc.
4 |*|
5 |*| This is intended to be the easiest section to edit
6 |*| some easy custom theming, (a custom color scheme, etc.).
7 |*|
8 \*/
9
10 :root {
11     /* Standard colors for text. */
12     --text-fg-color: #333738;
13     --text-fg-color-max-contrast: black;
14     --text-bg-color: white;
15     --outside-page-bg-color: #333738;
16
17     /* A little color to avoid a fully monochromatic theme. */
18     --accent-color: #287789;
19     --accent-color-bright: #44c7ef;
20
21     /* Some colors intended to convey semnatics. */
22     --warning-color: #ffa92a;
23     --danger-color: #f56257;
24     --danger-color-dark: #bc2822;
25
26     /* Page layout */
27     --page-max-width: 720px;
28     --page-max-pad: 50px;
29     --page-max-width-padded: calc(var(--page-max-width) + 2 * var(--page-max-pad));
30 }
31
32 /*\
33 |*|
34 |*| Core elements: Sizing, padding, and application of theme colors
35 |*|
36 \*/
37
38 body {
39     line-height: 1.25;
40     font-family: sans-serif;
41     color: var(--text-fg-color-max-contrast);
42 }
43
44 h1,h2 {
45     color: var(--text-fg-color);
46     font-weight: bold;
47 }
48
49 h1 {
50     font-size: 150%;
51 }
52
53 h2 {
54     font-size: 110%;
55 }
56
57 /* Don't underline links in headers */
58 h1 a {
59     text-decoration: none;
60 }
61
62 p,dl,dd,form {
63     margin-bottom: 1em;
64 }
65
66 ul li {
67     margin-left: 1em;
68     list-style-type: disc;
69     margin-bottom: 0.5em;
70 }
71
72 a:link    {
73     color: var(--accent-color);
74 }
75 a:visited {
76     color: var(--accent-color);
77 }
78 a:hover   {
79     color: var(--accent-color-bright);
80 }
81 a:active  {
82     color: var(--accent-color-bright);
83 }
84
85 /*\
86 |*|
87 |*| Overall page layout
88 |*|
89 |*| Assumes: Top-level div with id="page" for all content
90 |*|
91 \*/
92
93 /* Mobile-first: At small sized we have a white background and use the
94  * entire screen width for the page (so the background color of the
95  * body is not visible anywhere). */
96 body {
97     background-color: var(--outside-page-bg-color);
98 }
99
100 #page {
101     background-color: var(--text-bg-color);
102 }
103
104 /* For a small screen (in either width or height) change the
105  * background of the body element to white so the application always
106  * appears as if it is "full screen".
107  */
108 @media screen and (max-width: 500px) and (max-height: 860px) {
109     body {
110         background-color: var(--text-bg-color);
111     }
112 }
113
114 /* We never let the page content get larger than a large fixed width.
115  *
116  * And when the screen is wide enough, we can afford some "wasted"
117  * space on either side of the page content, (up to --page-max-pad).
118  *
119  * Note: This --page-max-width-padded for the page includes the
120  * padding so the actual content is only ever as wide as
121  * --page-max-width.
122  *
123  * Wider than that and we start to see the background on either side
124  * of the page content.
125  */
126 #page {
127     box-sizing: border-box;
128     max-width: var(--page-max-width-padded);
129     margin-left: auto;
130     margin-right: auto;
131     padding-top: 0;
132     padding-bottom: 2em;
133     padding-left: 1em;
134     padding-right: 1em;
135 }
136
137 @media screen and (min-width: var(--page-max-width)) and (max-width: var(--page-max-width-padded)) {
138     #page {
139         padding-left: calc(1em + (100% - var(--page-max-width))/2);
140         padding-right: calc(1em + (100% - var(--page-pax-width))/2);
141     }
142 }
143
144 @media screen and (min-width: var(--page-pax-width-padded)) {
145     #page {
146         padding-left: calc(1em + var(--page-max-pad));
147         padding-right: calc(1em + var(--page-max-pad));
148     }
149 }
150
151 /* The calculations for height are different. We don't have any
152  * vertical centering, so instead we have only some fixed padding on
153  * the top. Then, the margin which allows the background to be visible
154  * on the top and bottom starts appearing at a viewport height of 648
155  * and tops out at a size of 36px.
156  */
157 #page {
158     min-height: 500px;
159     padding-top: 1em;
160 }
161
162 @media screen and (min-height: 648px) and (max-height: 720px) {
163     #page {
164         margin-top: calc((100vh - 648px)/2);
165         margin-bottom: calc((100vh - 648px)/2);
166     }
167 }
168
169 @media screen and (min-height: 720px) {
170     #page {
171         margin-top: 36px;
172         margin-bottom: 36px;
173     }
174 }
175
176 /*\
177 |*|
178 |*| Responsive form layout
179 |*|
180 \*/
181
182 /*
183  *
184  * Within the form, fields can be placed in <div> elements with
185  * class "form-field". Each can also have an additional class of one
186  * of "small", "medium", or "large". These classes will be used to
187  * select either a 1- or 2-column layout for each row depending on the
188  * width of the screen.
189  *
190  * Expected layout is as follows:
191  *
192  *   "large"   rows: 1-column on all devices
193  *
194  *   "medium"  rows: 2-column on wide displays (laptop/desktop/tablet)
195  *                   1-column on small display (phones)
196  *
197  *   "small"   rows: 2-column on all devices
198  *
199  * Finally, a class of either "left" or "right" will select which
200  * column the field should appear in for fields that end up in 2
201  * columns.
202  */
203 form {
204     max-width: 100%;
205     display: grid;
206     grid-template-columns: 1fr 1fr;
207     grid-column-gap: 1em;
208 }
209
210 .form-field.small.left,.form-field.medium.left {
211     grid-column-start: 1;
212 }
213
214 .form-field.small.right,.form-field.medium.right {
215     grid-column-start: 2;
216 }
217
218 .form-field.large {
219     grid-column-start: 1;
220     grid-column-end: span 2;
221 }
222
223 /* For a narrow screen, use a single-column for medium form fields. */
224 @media screen and (max-width: 600px) {
225     .form-field.medium.left,.form-field.medium.right {
226         grid-column-start: 1;
227         grid-column-end: span 2
228     }
229 }
230
231 /*\
232 |*|
233 |*| Styling for form input fields
234 |*|
235 \*/
236
237 label {
238     font-size: 125%;
239 }
240
241 input {
242     box-sizing: border-box;
243     font-size: 125%;
244     height: 40px;
245     padding: 0.5em;
246     width: 100%;
247     border: 1px solid var(--accent-color);
248     border-radius: 4px;
249 }
250
251 input:focus {
252     border: 2px solid var(--accent-color-bright);
253 }
254
255 button {
256     display: inline-block;
257     border-radius: 4px;
258     background-color: var(--accent-color);
259     border: none;
260     color: white;
261     text-align: center;
262     font-size: 125%;
263     margin-top: .25em;
264     padding-top: 0.25em;
265     padding-bottom: 0.25em;
266     width: 200px;
267     cursor: pointer;
268 }
269
270 button.inline {
271     font-size: 72%;
272     font-weight: bold;
273     width: auto;
274 }
275
276 button:hover {
277     transform: translateY(-1px);
278     background-color: var(--accent-color-bright);
279 }
280
281 :focus {
282     outline: none;
283 }
284
285 ::-moz-focus-inner {
286     border: 0;
287 }
288
289 /*\
290 |*|
291 |*| Styling for a message area
292 |*|
293 \*/
294
295 /* Default message severity is "info" but can be overriden. */
296 .message {
297     padding: 1em;
298     background-color: var(--accent-color-bright);
299     color: white;
300     transition: 0.3s;
301     margin-bottom: 0.5em;
302     font-weight: bold;
303     border-radius: 4px;
304     position: relative;
305 }
306
307 .success {
308     background-color: var(--accent-color-bright);
309 }
310
311 .warning {
312     background-color: var(--warning-color);
313 }
314
315 .danger {
316     background-color: var(--danger-color);
317 }
318
319 .hide-button {
320     color: white;
321     font-size: 125%;
322     font-weight: bold;
323     cursor: pointer;
324     position: absolute;
325     right: 0.5em;
326     top: 0;
327 }
328
329 .hide-button:hover {
330     color: var(--danger-color-dark);
331 }
332
333 /*\
334 |*|
335 |*| Game-specific markup
336 |*|
337 \*/
338
339 .game-id, .players-header {
340     font-size: 110%;
341     font-weight: bold;
342 }