]> git.cworth.org Git - lmno.games/blob - style.css
Fix the page width to allow the content to be a full 720px wide
[lmno.games] / style.css
1 /*\
2 |*|
3 |*| Core elements: Sizing and padding
4 |*|
5 \*/
6
7 body {
8     line-height: 1.25;
9     font-family: sans-serif;
10 }
11
12 h1 {
13     font-size: 150%;
14     font-weight: bold;
15 }
16
17 h2 {
18     font-size: 110%;
19     font-weight: bold;
20 }
21
22 /*\
23 |*|
24 |*| Overall page layout
25 |*|
26 |*| Assumes: Top-level div with id="page" for all content
27 |*|
28 \*/
29
30 /* Mobile-first: At small sized we have a white background and use the
31  * entire screen width for the page (so the background color of the
32  * body is not visible anywhere). */
33 body {
34     background-color: #333738;
35 }
36
37 #page {
38     background-color: white;
39 }
40
41 /* For a small screen (in either width or height) change the
42  * background of the body element to white so the application always
43  * appears as if it is "full screen".
44  */
45 @media screen and (max-width: 500px) and (max-height: 860px) {
46     body {
47         background-color: white;
48     }
49 }
50
51 /* We never let the page content get larger than a large fixed width.
52  *
53  * And when the screen is wide enough, we can afford some "wasted"
54  * space on either side of the page content. This starts at 0 for a
55  * 620px wide page up to 50px on either side for a 820px wide page.
56  *
57  * Note: This 820px width for the page includes the padding so the
58  * actual content is only ever as wide as 720px.
59  *
60  * Wider than that and we start to see the background on either side
61  * of the page content.
62  */
63 #page {
64     box-sizing: border-box;
65     max-width: 820px;
66     margin-left: auto;
67     margin-right: auto;
68     padding-top: 0;
69     padding-bottom: 0;
70     padding-left: 1em;
71     padding-right: 1em;
72 }
73
74 @media screen and (min-width: 620px) and (max-width: 820px) {
75     #page {
76         padding-left: calc(1em + (100% - 820px)/2);
77         padding-right: calc(1em + (100% - 820px)/2);
78     }
79 }
80
81 @media screen and (min-width: 820px) {
82     #page {
83         padding-left: calc(1em + 50px);
84         padding-right: calc(1em + 50px);
85     }
86 }
87
88 /* The calculations for height are different. We don't have any
89  * vertical centering, so instead we have only some fixed padding on
90  * the top. Then, the margin which allows the background to be visible
91  * on the top and bottom starts appearing at a viewport height of 648
92  * and tops out at a size of 36px.
93  */
94 #page {
95     min-height: 500px;
96     padding-top: 1em;
97 }
98
99 @media screen and (min-height: 648px) and (max-height: 720px) {
100     #page {
101         margin-top: calc((100vh - 648px)/2);
102         margin-bottom: calc((100vh - 648px)/2);
103     }
104 }
105
106 @media screen and (min-height: 720px) {
107     #page {
108         margin-top: 36px;
109         margin-bottom: 36px;
110     }
111 }
112
113 /*\
114 |*|
115 |*| Responsive form layout
116 |*|
117 \*/
118
119 /*
120  *
121  * Within the form, fields can be placed in <div> elements with
122  * class "form-field". Each can also have an additional class of one
123  * of "small", "medium", or "large". These classes will be used to
124  * select either a 1- or 2-column layout for each row depending on the
125  * width of the screen.
126  *
127  * Expected layout is as follows:
128  *
129  *   "large"   rows: 1-column on all devices
130  *
131  *   "medium"  rows: 2-column on wide displays (laptop/desktop/tablet)
132  *                   1-column on small display (phones)
133  *
134  *   "small"   rows: 2-column on all devices
135  *
136  * Finally, a class of either "left" or "right" will select which
137  * column the field should appear in for fields that end up in 2
138  * columns.
139  */
140 form {
141     max-width: 100%;
142     display: grid;
143     grid-template-columns: 1fr 1fr;
144     grid-column-gap: 1em;
145 }
146
147 .form-field.small.left,.form-field.medium.left {
148     grid-column-start: 1;
149 }
150
151 .form-field.small.right,.form-field.medium.right {
152     grid-column-start: 2;
153 }
154
155 .form-field.large {
156     grid-column-start: 1;
157     grid-column-end: span 2;
158 }
159
160 /* For a narrow screen, use a single-column for medium form fields. */
161 @media screen and (max-width: 600px) {
162     .form-field.medium.left,.form-field.medium.right {
163         grid-column-start: 1;
164         grid-column-end: span 2
165     }
166 }
167
168 /*\
169 |*|
170 |*| Styling for form input fields
171 |*|
172 \*/
173
174 label {
175     font-size: 125%;
176 }
177
178 input {
179     box-sizing: border-box;
180     font-size: 125%;
181     padding: 0.5em;
182     width: 100%;
183     border: 1px solid #287789;
184     border-radius: 4px;
185 }
186
187 input:focus {
188     border: 2px solid #44c7ef;
189 }
190
191 button {
192     display: inline-block;
193     border-radius: 4px;
194     background-color: #287789;
195     border: none;
196     color: white;
197     text-align: center;
198     font-size: 125%;
199     margin-top: .25em;
200     padding-top: 0.25em;
201     padding-bottom: 0.25em;
202     width: 200px;
203 }
204
205 button:hover {
206     transform: translateY(-1px);
207     background-color: #44c7ef;
208 }
209
210 :focus {
211     outline: none;
212 }
213
214 ::-moz-focus-inner {
215     border: 0;
216 }
217
218 /*\
219 |*|
220 |*| Styling for a message area
221 |*|
222 \*/
223
224 /* Default message severity is "info" but can be overriden. */
225 .message {
226     padding: 1em;
227     background-color: #44c7ef;
228     color: white;
229     transition: 0.3s;
230     margin-bottom: 0.5em;
231     font-weight: bold;
232     border-radius: 4px;
233     position: relative;
234 }
235
236 .success {
237     background-color: #44c7ef;
238 }
239
240 .warning {
241     background-color: #ffa92a;
242 }
243
244 .danger {
245     background-color: #f56257
246 }
247
248 .hide-button {
249     color: white;
250     font-size: 125%;
251     font-weight: bold;
252     cursor: pointer;
253     position: absolute;
254     right: 0.5em;
255     top: 0;
256 }
257
258 .hide-button:hover {
259     color: #bc2822;
260 }